cli-tarHow do I use the Unix tar command to compress a file?
The tar command is a Unix utility used to create and manipulate tar archives. To compress a file with the tar command, use the following syntax:
tar -czf <filename>.tar.gz <file_or_directory_to_compress>
This command will create a tar.gz archive of the specified file or directory.
The parts of the command are:
tar: The command to run-czf: The flags used to compress and create a new archive<filename>.tar.gz: The name of the new archive<file_or_directory_to_compress>: The file or directory to compress
For example, to compress the file example.txt, you would run the command:
tar -czf example.tar.gz example.txt
This will create a example.tar.gz archive containing the example.txt file.
Helpful links
More of Cli Tar
- How do I use the command line to tar and zip files?
- How can I use tar commands to zip a file?
- How do I use the shell to tar and zip files?
- How do I use the Unix tar zip command?
- How do I create a tar.zip file in Unix?
- 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 gzip, tar, and zip to compress files?
- 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?
See more codes...