cli-tarHow can I compress multiple files using tar and gzip in parallel?
Using GNU Parallel, you can compress multiple files using tar and gzip in parallel. To do this, you need to create a tar archive of the files you want to compress and then pass the tar archive to gzip.
The following example code will compress the files file1.txt
and file2.txt
into files.tar.gz
:
tar cvf files.tar file1.txt file2.txt
gzip files.tar
The output of the above code will be:
file1.txt
file2.txt
To compress these files in parallel, you can use the following command:
parallel gzip ::: files.tar
The output of the above command will be:
files.tar.gz
The code can be broken down as follows:
parallel
: This is the command for running commands in parallel.gzip
: This is the command for compressing files using gzip.:::
: This is the separator for the list of files to be compressed.files.tar
: This is the tar archive containing the files to be compressed.
Helpful links
More of Cli Tar
- How do I use the Unix tar zip command?
- How do I use the command line to tar and zip files?
- How do I create a tar.zip file in Unix?
- How do I use the command line to tar and distribute files?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and zip a file?
- How can I use tar commands to zip a file?
- How do I use gzip, tar, and zip to compress files?
- How do I use the shell to tar and zip files?
- How do I use the command line to tar and zip a file?
See more codes...