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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command to find certain words in a file searching after another word

Status
Not open for further replies.

dbadmin

Programmer
Jan 3, 2003
147
US
Hi gurus,

I need a command to search all files under a directory for a word "beat" and then print another line in the same file with the word "Elapsed"

A typical file will have text like below

Item1 bottle beat
Elapsed:01:01:01

The command "find . -type f -print |xargs grep -i beat" will give all the file names which has a word "beat", how can I print the line Elapsed from the same file.

Any help is really appreciated.

Thanks,
dbadmin
 
Maybe...

grep -l beat * | xargs -l grep Elapsed

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top