![]() |
|
|
|
|
|||||||
| 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 |
| Using grep to extract line number | mskarica | Shell Programming and Scripting | 8 | 06-25-2008 11:47 PM |
| How to grep / zgrep to output ONLY the matching filename and line number? | vvaidyan | UNIX for Dummies Questions & Answers | 3 | 03-12-2008 02:33 PM |
| Grep a number from a line in ksh | rodluo | Shell Programming and Scripting | 3 | 12-09-2007 06:31 AM |
| grep the string with the line number | salaathi | Shell Programming and Scripting | 4 | 12-04-2007 08:42 AM |
| Get Filename and Line Number using grep | ceemh3 | UNIX for Dummies Questions & Answers | 4 | 09-17-2007 07:35 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
is there any why to get the number of line in grep result ?
Hello all
when I do simple grep on file im getting the results of "filename : stringResult " is there any way to present also the line number in the file ? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
GNU grep provides a -n option.
Code:
-n, --line-number
Prefix each line of output with the line number within its input
file.
nl haystack | grep "needle" Not sure if nl is available on non-Linux systems. |
||||
| Google The UNIX and Linux Forums |