|
what is wrong in this awk or grep ....
hi champs,
i have a strange problem,
let ,
i have a array1, whose 1st character is ${array1[0]}=h
let i want to search test.txt by awk/grep where the 1st character is the ${array1[0]}....
if i am seraching by awk/grep by using variable..it return no rows from test.txt...
awk -v find=${array1[0]} '/^find.*/ {print $0}' test.txt
grep '^${array1[0]}.*' test.txt
but if i am doing it by following methods, strangely it gives me the xact o/p
grep '^h.*' test.txt
awk '/^h.*/ {print $0}' test.txt
any suggesttion , how to make my search dynamic.....or what is the problem in above awk/grep
|