Look at the following unix shell script:
echo "Enter the pattern to be searched: \c"
read pname
echo "Enter the file to be used: \c"
reac flname
echo "Searching $pname from the file $flname."
grep "$pname" $flname
echo "The search results are displayed above."
Please pay attention to the grep line. The code works fine whether $pname is enclosed by curly braces or not. Now I wanna try awk.
echo "Enter the pattern to be searched: \c"
read pname
echo "Enter the file to be used: \c"
reac flname
echo "Searching $pname from the file $flname."
awk 'BEGIN { FS = ":" }
$3 ~ /"$pname"/' $flname
echo "The search results are displayed above."
Now the problem is : Whether the $pname has curly braces around it, the awk part doesn't function. Why is it? Is there any way to make awk part work?