LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep question (https://www.linuxquestions.org/questions/linux-newbie-8/grep-question-251083/)

djgerbavore 11-04-2004 11:37 AM

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

lethargo 11-04-2004 11:46 AM

I believe there is a -n switch (or it's long version --line-number). E.g...
?>cat file | grep -n "something"

lthaus 11-04-2004 11:52 AM

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.

djgerbavore 11-04-2004 11:53 AM

thank you, -n worked


All times are GMT -5. The time now is 01:36 PM.