Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: using tar command to zip files - bash

  1. #11
    Join Date
    Oct 2014
    Location
    Rotterdam
    Posts
    869

    Default Re: using tar command to zip files - bash

    Probably relevant for this: The Unix Tools Philosophy

    Yes, gzip can compress only one file, tar primary usage is to store multiple files in a single file (an archive)

    If you do not want to use pipes, you can use tar's compress options to specify what it should do as additional compress/decompress step:

    Code:
    Compression options
           -a, --auto-compress
                  Use archive suffix to determine the compression program. 
    
           -I, --use-compress-program=COMMAND
                  Filter data through COMMAND.  It must accept the -d option, for decompression.  The argument can contain command line options. 
    
           -j, --bzip2
                  Filter the archive through bzip2(1). 
    
           -J, --xz
                  Filter the archive through xz(1). 
    
           --lzip Filter the archive through lzip(1). 
    
           --lzma Filter the archive through lzma(1). 
    
           --lzop Filter the archive through lzop(1). 
    
           --no-auto-compress
                  Do not use archive suffix to determine the compression program. 
    
           -z, --gzip, --gunzip, --ungzip
                  Filter the archive through gzip(1). 
    
           -Z, --compress, --uncompress
                  Filter the archive through compress(1). 
    
           --zstd Filter the archive through zstd(1).

  2. #12

    Default Re: using tar command to zip files - bash

    Code:
    tar -czf "/var/log/VirusVault/VirusFound_${Current_Date}.zip" -C "/var/log/VirusVault" "VirusFound_${Current_Date}" --remove-files
    I'm currently filtering through gzip, but I have others to filter through.

    It worked with this change.

    tar -caf "/var/log/VirusVault/VirusFound.zip" -C "/var/log/VirusVault" "VirusFound" --remove-files

    Now, what compression format is it in to be compatible with mswin.

  3. #13

    Default Re: using tar command to zip files - bash


  4. #14

    Default Re: using tar command to zip files - bash

    Code:
    tar -caf "/var/log/VirusVault/VirusFound.tar.gz" -C "/var/log/VirusVault" "VirusFound" --remove-files
    It works, only one level. I've seen 'tar.gz' to zip conversion scripts, but just letting the user convert it to zip format is simpler.

    I need to look and see what linux compression formats mswin10 can use.

    Unless someone has a better idea, this works. Thanks for the assistance...

  5. #15
    Join Date
    Sep 2012
    Posts
    8,257

    Default Re: using tar command to zip files - bash

    Quote Originally Posted by lord_valarian View Post
    Code:
    tar -czf "/var/log/VirusVault/VirusFound_${Current_Date}.zip" -C "/var/log/VirusVault" "VirusFound_${Current_Date}" --remove-files
    it creates a double layer compressed file.
    Quote Originally Posted by lord_valarian View Post
    Code:
    tar -caf "/var/log/VirusVault/VirusFound.tar.gz" -C "/var/log/VirusVault" "VirusFound" --remove-files
    It works, only one level.
    These two commands create byte for byte identical files.
    Code:
    bor@bor-Latitude-E5450:/tmp$ tar -czf xxx.zip xxx
    bor@bor-Latitude-E5450:/tmp$ tar -caf xxx.tar.gz xxx
    bor@bor-Latitude-E5450:/tmp$ cmp xxx.zip xxx.tar.gz 
    bor@bor-Latitude-E5450:/tmp$ echo $?
    0
    bor@bor-Latitude-E5450:/tmp$

  6. #16

    Default Re: using tar command to zip files - bash

    Quote Originally Posted by arvidjaar View Post
    These two commands create byte for byte identical files.
    Code:
    bor@bor-Latitude-E5450:/tmp$ tar -czf xxx.zip xxx
    bor@bor-Latitude-E5450:/tmp$ tar -caf xxx.tar.gz xxx
    bor@bor-Latitude-E5450:/tmp$ cmp xxx.zip xxx.tar.gz 
    bor@bor-Latitude-E5450:/tmp$ echo $?
    0
    bor@bor-Latitude-E5450:/tmp$
    Code:
    tar -czf "/var/log/VirusVault/VirusFound.zip" -C "/var/log/VirusVault" "VirusFound" --remove-file
    click on VirusFound-->
    opens VirusFound arc -->
    displays: VirusFound.zip ------------- uncompressed
    click on VirusFound.zip -->
    displays folder VirusFound

    If it's double level archive, how can the files be identical? -czf = -caf

    Same compression for both commands?

  7. #17

    Default Re: using tar command to zip files - bash

    KDE can do a zip with a right-click on file with the folder, holding the original file structure. How does KDE do this?

  8. #18

    Default Re: using tar command to zip files - bash

    I'm getting off topic, so this topic is closed.

    Thanks to all. The problem is fixed.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •