![]() |
|
|
|
|
|||||||
| 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 |
| generating line numbers | sam4now | Shell Programming and Scripting | 7 | 04-28-2008 03:17 PM |
| Need help capturing end of line numbers | icalderus | SUN Solaris | 3 | 09-20-2007 11:34 PM |
| how to print out line numbers of a text file? | forevercalz | Shell Programming and Scripting | 4 | 12-12-2005 02:04 AM |
| add line numbers | esham | Shell Programming and Scripting | 4 | 03-07-2005 07:46 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Question About Getting Line Numbers in a File
Ok, this is a unique question.
Say I have a word like "jamamamama" in a file called foo.bar. Now, how do you get the line number that the word "jamammama" exist in the file foo.bar without having to go into the foo.bar file to edit it? is there a command i can run on the foo.bar command to get the line number? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Try grep -n [filename]
|
|
#3
|
||||
|
||||
|
It should be like this,
Code:
grep -n "jamamamama" [filename] |
|
#4
|
|||
|
|||
|
Code:
awk '/pattern/ { print NR }' filename
|
|
#5
|
|||
|
|||
|
Code:
$ sed -n '/jamamamama/=' filename |
|||
| Google The UNIX and Linux Forums |