Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 954 Bytes

gzip.md

File metadata and controls

31 lines (21 loc) · 954 Bytes

gzip, gunzip, zcat: Compress and uncompress files

The gzip, gunzip, and zcat commands are used to compress files. One can use tar with the -z option to invoke gzip. gzip will compress a file, gunzip will uncompress it and zcat will allow you to review the contents of the gzipped files.

We can compress the contents of our Desktop like we did with the tar command:

cd ~
gzip --help

From the gzip manual we will use the -c and -r flags below:

gzip -c -r ~/cli_workshop/data_files/ > /tmp/data_files.gz

You can compare the sizes of the tarred file and the gzipped one using ls.

Let's review the contents of the file using zcat by piping that into less

zcat /tmp/data_files.gz | less

Finally you can send this file much easier to another user who will open it using.

gunzip /tmp/data_files.gz

More on gzip