printing line number

hi,
i have a file, i need to search for a string , if the line contains i need to print that line number and line ,
please help

thanks in advance
Satya

cat -n <filename> | grep <string>

these will also do

awk '/searchstring/{print NR" "$0}' filename

try this also

sed = filename|sed -n 'N;s/\n/ /g;/searchstring/p'

That's an unnecessary use of cat, just use grep -n

$ cat test.txt
grep  searches the named input FILEs (or standard input if no files are
       named, or the file name - is given) for lines containing a match to the
       given PATTERN.  By default, grep prints the matching lines.

$ cat -n test.txt | grep default
     3         given PATTERN.  By default, grep prints the matching lines.

$ grep -n default test.txt
3:       given PATTERN.  By default, grep prints the matching lines.

[/quote]

Using Ruby

ruby -ne 'printf("%-4s %s", $., $_) if $_ =~/searchstring/' file