9951 explained code solutions for 126 technologies


cli-tarHow do I gzip a tar file?


To gzip a tar file, you can use the following command:

tar -zcvf <output_file.tar.gz> <input_file.tar>

This command will create a gzipped tar file called output_file.tar.gz based on the input_file.tar. The flags used are:

  • z for gzip compression
  • c to create a new archive
  • v for verbose output
  • f to specify the output file

The output of the command will look like this:

input_file.tar
input_file.tar
input_file.tar
...

To uncompress the tar file, you can use the command:

tar -zxvf <input_file.tar.gz>

This will extract the files from the gzipped tar file. The flags used are:

  • z for gzip decompression
  • x to extract files from the archive
  • v for verbose output
  • f to specify the input file

The output of the command will look like this:

input_file.tar
input_file.tar
input_file.tar
...

Helpful links

Edit this code on GitHub