The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 06:17 PM
Need help capturing end of line numbers icalderus SUN Solaris 3 09-21-2007 02:34 AM
how to print out line numbers of a text file? forevercalz Shell Programming and Scripting 4 12-12-2005 05:04 AM
add line numbers esham Shell Programming and Scripting 4 03-07-2005 10:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-19-2008
SkySmart SkySmart is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 48
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?
  #2 (permalink)  
Old 08-19-2008
s_becker s_becker is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 28
Try grep -n [filename]
  #3 (permalink)  
Old 08-20-2008
ynilesh's Avatar
ynilesh ynilesh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 222
It should be like this,
Code:
grep -n "jamamamama" [filename]
- nilesh
  #4 (permalink)  
Old 08-20-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Code:
awk '/pattern/ { print NR }' filename
  #5 (permalink)  
Old 08-20-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,912
Code:
$ sed -n '/jamamamama/=' filename
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0