LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-04-2004, 11:37 AM   #1
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
grep question


i want to grep something, however is there a way it will tell me hte line number also?

?>cat file | grep "something"
12: something

is this possible?????

i tried man grep, but was unsuccessful..
thanks
djgerbavore
 
Old 11-04-2004, 11:46 AM   #2
lethargo
LQ Newbie
 
Registered: Aug 2003
Location: St. Paul, Minnesota, US
Distribution: Slackware 10
Posts: 27

Rep: Reputation: 15
I believe there is a -n switch (or it's long version --line-number). E.g...
?>cat file | grep -n "something"
 
Old 11-04-2004, 11:52 AM   #3
lthaus
LQ Newbie
 
Registered: Nov 2004
Posts: 6

Rep: Reputation: 0
Quote:
Originally posted by lethargo
I believe there is a -n switch (or it's long version --line-number). E.g...
?>cat file | grep -n "something"
wrong command.... right option...



cat -n file | grep whatever


[z535104@bmcsnt01 Servers]$ cat -n test.sh | grep ssh
6 # System dir has list of systems with it linked to a ./telnet and ./ssh so
15 #SSH=`which ssh`
19 SSH="/usr/bin/ssh -l $USER"

v.
 
Old 11-04-2004, 11:53 AM   #4
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Original Poster
Rep: Reputation: 30
thank you, -n worked
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about Grep irfanhab Linux - Newbie 6 08-23-2004 03:57 PM
grep question djgerbavore Linux - Newbie 7 07-07-2004 08:11 AM
grep question Hockeyfan Linux - General 1 05-15-2004 03:09 AM
grep question vasanthraghavan Programming 3 04-23-2004 01:32 AM
grep question keyops Programming 2 04-09-2004 10:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration