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 09-11-2007
ceemh3 ceemh3 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 3
Get Filename and Line Number using grep

Hi,

I am using the Korne shell to try and get the filename, line number and the line of text using grep e.g.

find ./ -type f -name "*.java" -exec grep -nf test.txt '{}' \;
(test.txt contains strings to search)

will return the line number and the line of text.

grep -l would return the filename but grep -ln doesnt return the filename, the line number and the line of text.

Is it possible to do this using grep ?, or would I have to use something like awk ?

I would appreciate if anybody can help me

thanks

Last edited by ceemh3; 09-11-2007 at 10:22 AM..