Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More awk help

Status
Not open for further replies.

chomps303

MIS
Sep 30, 2003
83
US
Why won't this work?

clear
echo "Enter Search String \c"
read search
echo "Enter Filename to Search \c"
read filename
fln=`awk '/$search/{printf "%d\n",NR}' $filename`
echo "Line Number =" $fln

Thanks

Brandt
 
$search will not be expanded to the value of the variable because it is between single quotes.

Try:

fln=`awk '/'"$search"'/{printf "%d\n",NR}' $filename`

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top