![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| GREP and Retrieve Line by Line | maxmave | Shell Programming and Scripting | 2 | 06-03-2008 08:45 AM |
| Grep a number from a line in ksh | rodluo | Shell Programming and Scripting | 3 | 12-09-2007 06:31 AM |
| grep the line only if next line matches | pbsrinivas | Shell Programming and Scripting | 11 | 07-10-2007 05:51 AM |
| Grep using line command | PradeepRed | Shell Programming and Scripting | 3 | 12-16-2005 10:37 AM |
| grep only one line | asoosai | UNIX for Dummies Questions & Answers | 3 | 05-30-2003 11:04 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to grep only 1st line
how to grep the line no of the first pattern match in a file having multiple line of pattern match.
linke i want to know the line no for the word "the" the first time it appears in the file, now a file is going to have the word "the" many times.. how to grep the first line no for me -m 1'the' or -m 1"the" is not working!!! kindly suggest somthing.. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
sed -n '/the/=' file Code:
grep -n "the" file | head -n 1 |
|
#3
|
|||
|
|||
|
thnx man!!!
|
|
#4
|
|||
|
|||
|
Code:
awk '/the/ { print NR; exit }' file
|
|||
| Google The UNIX and Linux Forums |