Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grep question

Status
Not open for further replies.

stephenk1973

Technical User
Jun 11, 2003
246
0
0
GB
I have a long list of directory/files which contain a phrase. I obtain this using....

fgrep -l phrase * > file

This is good, but it is a parameter after the phrase on the same line which i really require. Can i modify this so that the line is printed as well as the file name and location.

Thanks

Stephen
 
could you post an example pls? with the source and what you need..

thanks
 
There are number of report files in a number of directories, some of which contain a phrase, the phrase declares a numeric format.....

.declare phrase 99999999

The phrase is about to 'roll over' and require another digit. I would like to list the file name,location and the line for each occurence of the phrase so that i will be able read which report files are effected and therefore adjust them.

Thanks

Stephen
 
Maybe something like this..

fgrep -l phrase | awk -F {$3} | grep 9999999 * > file

basically grab the number via awk then grep for 9999999

I am not at work so I can't comfirm the syntax but should lead you in a direction not sure if it will be the direction you are looking for but I tried.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top