file1
" and rename it to "file1.gz
":
$ touch file1
$ ls -al file1 -rw-r--r-- 1 mtitek mtitek 5632 Feb 3 21:01 file1
$ gzip file1
$ ls -al file1.gz -rw-r--r-- 1 mtitek mtitek 242 Feb 3 21:01 file1.gz
file1.gz
" and rename it to "file1
":
$ gzip -d file1.gz
$ ls -al file1 -rw-r--r-- 1 mtitek mtitek 5632 Feb 3 21:01 file1
gunzip
):gunzip
to decompress the file "file1.gz
" and rename it to "file1
":
$ gunzip file1.gz
$ ls -al file1 -rw-r--r-- 1 mtitek mtitek 5632 Feb 3 21:01 file1
-k
option to keep the original file:
$ gzip -k file1
$ ls -al file1* -rw-r--r-- 1 mtitek mtitek 5632 Feb 3 21:01 file1 -rw-r--r-- 1 mtitek mtitek 242 Feb 3 21:01 file1.gz
-l
option to view compression statistics:
$ gzip -l file1.gz compressed uncompressed ratio uncompressed_name 242 5632 96.8% file1
$ gzip file1 file2 file3
$ ls -al file*.gz -rw-r--r-- 1 mtitek mtitek 242 Feb 3 21:01 file1.gz -rw-r--r-- 1 mtitek mtitek 156 Feb 3 21:01 file2.gz -rw-r--r-- 1 mtitek mtitek 089 Feb 3 21:01 file3.gz
-1
for fastest compression or -9
for best compression:
$ gzip -1 file1 # fastest compression $ gzip -9 file1 # best compression
-t
option to test file integrity:
$ gzip -t file1.gzIf the file is corrupted, you'll see an error message. No output means the file is intact.
-c
to write to stdout and keep the original file:
$ gzip -c file1 > file1.gz
$ ls -al file1* -rw-r--r-- 1 mtitek mtitek 5632 Feb 3 21:01 file1 -rw-r--r-- 1 mtitek mtitek 242 Feb 3 21:01 file1.gz
zcat
to view the contents of compressed files:
$ zcat file1.gzYou can also use
zless
or zmore
for paging through large files.