cli-tarHow do I use gzip or tar to compress a file?
Using gzip or tar to compress a file is a simple process.
To compress a file using gzip, use the following command:
gzip <filename>
This will create a new file with the same name but with the extension .gz. The original file will remain unchanged.
To compress a file using tar, use the following command:
tar -zcvf <filename>.tar.gz <filename>
This will create a new file with the extension .tar.gz. The original file will remain unchanged.
Code explanation
gzip: command to compress a file using gzip<filename>: name of the file to be compressedtar: command to compress a file using tar-zcvf: flags used with tar to compress the file.tar.gz: extension of the compressed 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 command line to tar and zip a file?
- 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 Unix tar zip command?
- How do I use the Unix tar xvf command?
- How do I use the command line to create a tar file?
- How do I use the tar command on Windows?
- How can I fix an unexpected end of file error when compressing a file with tar and gzip?
See more codes...