Search gzipped files

zcat /usr/share/man/man1/grep.1.gz | grep "color"
This decompresses the file and sends the output to STDOUT so it can be grepped. A good one to put in loops for searching directories of gzipped files, such as man pages.
Sample Output
groups of context lines) with escape sequences to display them in color
The colors are defined by the environment variable
This variable specifies the color used to highlight matched (non-empty) text.
It can only specify the color used to highlight
Specifies the colors and other attributes
The default is empty (i.e., the terminal's default color pair).
The default is empty (i.e., the terminal's default color pair).
each time a colorized item ends.

-7
By: root
2009-02-04 09:38:45

These Might Interest You

  • This will print out the files and directories in a gzipped tarball.


    -1
    less file.tar.gz
    allbad · 2009-03-15 23:00:05 5
  • Sets the size of the disk to $DISKSIZE so that the percentage readout of pv is correct. set /dev/sdb to whatever your disk is /dev/sdX. Next pipe dd to pv, then pipe pv to gzip so that you get a gzipped image file. Show Sample Output


    0
    DISKSIZE=`sudo blockdev --getsize64 /dev/sdb` && sudo dd bs=4096 if=/dev/sdb | pv -s $DISKSIZE | sudo gzip -9 > ~/USBDRIVEBACKUP.img.gz
    frame45 · 2016-08-31 00:03:56 0
  • Yeah, there are many ways to do that. Doing with sed by using a for loop is my favourite, because these are two basic things in all *nix environments. Sed by default does not allow to save the output in the same files so we'll use mv to do that in batch along with the sed. Show Sample Output


    -3
    for files in $(ls -A directory_name); do sed 's/search/replaced/g' $files > $files.new && mv $files.new $files; done;
    bassu · 2009-05-07 20:13:07 6
  • with discard wilcards in bash you can "tail" newer logs files to see what happen, any error, info, warn... Show Sample Output


    5
    tail -f *[!.1][!.gz]
    piscue · 2009-03-06 16:24:44 3

What Others Think

Better use zgrep instead: zgrep color /usr/share/man/man1/grep.1.gz
eterps · 489 weeks and 1 day ago
Agreed, zgrep is better because zcat wont cat non-gzipped files whereas zgrep does.
lucasrangit · 451 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: