Reputation: 1338
I am trying to search a pattern stored in awk array "a" read from file1 and then search in 4rth column of file2 , the following command works perfectly
awk -F" " 'NR==FNR{a[NR]=$1;next}{for (i in a){ if($4 ~ a[i])print $0}}' file1 file2
but If I change the command at if
to search at the start of 4rth column of file2 as shown below , it does not work , any suggestions please ?
awk -F" " 'NR==FNR{a[NR]=$1;next}{for (i in a){ if($4 ~ "^a[i]" )print $0}}' file1 file2
can the second command be modified to search the array element at the start of 4rth column in file2 ?
Upvotes: 3
Views: 884