Search the shell variable inside awk

view full story

http://www.unix.com – Hai, I need to search a variable inside a file using awk in AIX. for ex: file.txt one two three four five i need to get the lines with two awk '/two/ {print}' file.txt But i need to change the two as a variable since it would be changed on runtime..i tried like below..nothing give me the result Code: awk -v a=two '/a/ {print}' file.txt awk -v a=two '/'$a'/ {print}' file.txt Please advise (HowTos)