The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-19-2008
Registered User
 

Join Date: Dec 2006
Posts: 18
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?
Reply With Quote
Forum Sponsor
  #2  
Old 08-19-2008
Registered User
 

Join Date: Jul 2008
Posts: 15
Try grep -n [filename]
Reply With Quote
  #3  
Old 08-20-2008
ynilesh's Avatar
Registered User
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 174
It should be like this,
Code:
grep -n "jamamamama" [filename]
- nilesh
Reply With Quote
  #4  
Old 08-20-2008
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Code:
awk '/pattern/ { print NR }' filename
Reply With Quote
  #5  
Old 08-20-2008
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
Code:
$ sed -n '/jamamamama/=' filename
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0