The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-12-2008
vvaidyan vvaidyan is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 15
How to grep / zgrep to output ONLY the matching filename and line number?

Hi all,
I am trying to zgrep / grep list of files so that it displays only the matching filename:line number and does not display the whole line, like:

(echo "1.txt";echo "2.txt") | xargs zgrep -no STRING

If I use -o option, it displays the matching STRING and if not used, displays the whole matching line. I don't want to display the line content. Just the filename and linenumber needs to be displayed.

I am also trying to play around with awk.

Any response will be highly appreciated.

Thanks in advance,
vvaidyan