cli-tarHow do I compress a directory using gzip and tar?
Using gzip and tar together is a convenient way to compress a directory. The following example code will compress a directory called "mydir" into a single gzipped tarball file called "mydir.tar.gz":
tar -zcvf mydir.tar.gz mydir
The flags used in the command are as follows:
-z
: Compress the tarball with gzip-c
: Create a new tarball-v
: Verbosely show the progress-f
: Specify the filename of the tarball
The output of the command should look something like this:
$ tar -zcvf mydir.tar.gz mydir
mydir/
mydir/file1.txt
mydir/file2.txt
mydir/subdir1/
mydir/subdir1/file3.txt
mydir/subdir2/
mydir/subdir2/file4.txt
For more information, see the GNU tar manual.
More of Cli Tar
- How do I use the Unix tar zip command?
- How do I use the shell to tar and zip files?
- How can I use tar commands to zip a file?
- How do I use the command line to tar and distribute files?
- How do I use the Unix tar xvf command to extract files?
- How can I use the CLI tar yarn command to compress files?
- How do I use the tar command on Windows?
- How do I use gzip to compress a tar file on Windows?
- How do I compare Unix tar and zip files?
- How do I create a tar.zip file in Unix?
See more codes...