Monday, October 31, 2022

Reading Unix Compressed files without uncompressing them using Zcat, Zless, Zgrep, Zdiff

 

Mostly we have situation that we  need to  see content  of compressed  files without actually  uncompressing it . This  can be achieved using Z commands 



Below are options using z commands 

Viewing the compressed file with zcat.
Paging the compressed file with zless / zmore.
Searching inside the compressed file with zgrep / zegrep.
Comparison of file using zdiff / zcmp



Below are examples : 

$ zcat big-file.txt.gz 
[Note: View the file without uncompressing it]


zcat big-file.txt.gz > big-file.txt
[Note: Uncompress the file]



$ zcat filename.gz | more
$ zcat filename.gz | less

(or)

$ zless filename.gz
$ zmore filename.gz



$ zgrep -i less test-file.txt.gz



$ zdiff file1.txt.gz file2.txt.gz


No comments:

Post a Comment