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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 03-16-2006
Registered User
 

Join Date: Aug 2005
Posts: 229
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 ?
Reply With Quote
Forum Sponsor
  #2  
Old 03-16-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
GNU grep provides a -n option.

Code:
       -n, --line-number
              Prefix each line of output with the line number within its input
              file.
You could also try this

nl haystack | grep "needle"

Not sure if nl is available on non-Linux systems.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:19 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