get line number of a searched string

by Ramya 2011-08-30 14:41:34

get line number of a searched string

Use "Grep" command to get line number of a searched string.

myVar=` grep -n "Search string" file | cut -f1 -d:`
echo $myVar


Razz
Razz
Razz
Razz

Tagged in:

1059
like
0
dislike
0
mail
flag

You must LOGIN to add comments