====== Grep compressed (.gz) files at a shell prompt == by [[http://www.cyberciti.biz/tips/about-us|nixCraft]] on March 29, 2007 - last updated at January 29, 2008 **Q**. I've lots of .gz files in my directory and I'd like to search them using grep. Unfortunately, grep is not working on my compressed file. How do I write a script to automate entire procedure to grep some compressed files. Do I have to uncompress them first and run grep over them? **A**. No you don't have to uncompress file. Linux and UNIX comes with z-commands. zgrep invokes grep on compressed or gzipped files. All options specified are passed directly to grep. To search .gz file called test.gz, enter: $ zgrep 'word-to-search' /path/to/test.gz $ zgrep 'GET /faq/a-long-url/' /path/to/access.log.gz You can run zcat command to display file on screen: $ zcat file.gz Update: See list of all [[http://www.cyberciti.biz/tips/decompress-and-expand-text-files.html|z-commands]]