cli-tarHow do I create a gzip tar example?
Creating a gzip tar example is a simple process. First, create a directory and populate it with files that you want to compress.
mkdir example
echo "This is a test" > example/test.txt
Next, use the tar command to create a tar archive of the directory.
tar -cf example.tar example/
Finally, use the gzip command to compress the tar archive.
gzip example.tar
The resulting file, example.tar.gz
is a gzip compressed tar archive.
Code explanation
mkdir example
: creates a directory calledexample
echo "This is a test" > example/test.txt
: creates a file calledtest.txt
in theexample
directorytar -cf example.tar example/
: creates a tar archive of theexample
directorygzip example.tar
: compresses the tar archive with gzip
Helpful links
More of Cli Tar
- How do I use the command line to tar and zip files?
- How do I use the Unix tar zip command?
- How do I use gzip, tar, and zip to compress 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 command line to tar and zip a file?
- How do I use the command line to tar and zip a file?
- How do I use the shell to tar and zip files?
- How do I create a tar.zip file in Unix?
- How do I compare Unix tar and zip files?
See more codes...