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 for first matching line only

Status
Not open for further replies.

wtrepani

MIS
May 30, 2002
93
0
0
US
Hi all,

I have a file where many lines contain the text "wtrepani". I want to grep the file and get only the first line it finds back, then exit. Anyone know how to do this?

Thanks

Will
 
Hello Will,

try this:

grep wtrepani <filename>|head -1


bye

Jürgen
 
Or:
Code:
awk '/wtrepani/{print;exit}' <file>
Cheers, Neil :)
 
:) there's more than one way to do it - as someone or other once said... Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884
 
grep -m 1 &quot;wtrepani&quot; file


crowe
 
-m ? what does that do? I had a look at the Solaris and Linux man pages and couldn't see it, did I just miss the option? Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top