cli-tarHow do I compress a single file using tar and gzip?
Compressing a single file using tar and gzip requires two steps:
- Create a tar file containing the file to be compressed:
tar -cf <file_name>.tar <file_to_compress>
This command will create a tar file named <file_name>.tar containing the file <file_to_compress>.
- Compress the tar file using gzip:
gzip <file_name>.tar
This command will compress the tar file, creating a file named <file_name>.tar.gz.
The resulting <file_name>.tar.gz file is the compressed version of the original file.
Code explanation
tar -cf <file_name>.tar <file_to_compress>: creates a tar file containing the file to be compressedgzip <file_name>.tar: compresses the tar file using gzip
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 use the Unix tar zip command?
- How do I create a tar.zip file in Unix?
- How do I create a tar.gz file using a shell script?
- How do I tar a folder and its subfolders in Unix?
- How do I use the command line to create a tar file?
- How do I use tar commands with xz?
- How do I extract files from a tar archive using the cmd command?
See more codes...