tar -czf "/var/log/VirusVault/VirusFound_${Current_Date}.zip" -C "/var/log/VirusVault" "VirusFound_${Current_Date}" --remove-files
I couldn’t get zip to work with folders. So, I made this command. However, it creates a double layer compressed file. Can someone explain why it’s doing this?
I need the ability to compress as zip and other formats.
Yes, you are correct. I apologize. I tried with the the search functionality on the HTML page version of the man page, but should have made that case sensitive. Now I missed it :(.
I should not have answered this post because I never ventured further into tar then the traditional usage. Using in fact only a subset of the command characters like c, x, f and v. Nowadays I do use z, but was used to piping through the compressing tool of choice.
I can install the ‘zip’ command with Yast. It functions better, but I has to be installed. ‘gzip’ won’t work. I need a structured folder. Winrar linux also does this type.
Is there anyway to structure the ‘tar’ command to make it single level zip file?
file2.zip (uncompressed - click to open the uncompressed file)
tar -czf "/root/bin/VirusFound.zip" -C "/root/bin" "VirusFound" --remove-files
If you run this command with some text files in the folder, you need to click once to open the zip and click the zip inside the zip file to get the folder.
‘gzip’ won’t do structured nested/multi-level folders. ‘tar’ will with this command with the double zip storage. ‘gzip’ will only compress all the files in those nested folders. The ‘zip’ (installed) command will do it.
‘gzip’ can’t do a structured folders. So far, no webpages tell me how to that with gzip. ( ‘-’ tr ’ [space]’ )
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:
**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).