My file, aaa,has 5 lines.01_AAA-11-ID2202_BBB-33-ID4403_CCC-55-ID66..I tried to grep anything after underline from a file bigfile.txtfor i in $(cat aaa)doA= $(awk -F '_' '{print $1}' $i)B= $(awk -F '_' '{print $2}' $i)grep $B bigfile.txt > $AdoneI tried to do grep AAA-11-22 bigfile.txt > 01But, it seems not working. My error code is awk: cmd. line:1: fatal: cannot open file `01_AAA-11-22' for reading (No such file or directory)Need some advise. Thanks,
grep a awk string from a file and write to the other part of string file
shell script;awk;grep
echo $i instead of trying to open it as a file:for i in $(cat aaa)do  A= $(echo $1 | awk -F '_' '{print $1}')  B= $(echo $i | awk -F '_' '{print $2}')  grep $B bigfile.txt > $AdoneHowever, if you are interested, you could replace this for-loop entirely with an awk one-liner:awk -F '_' '{system(grep $2 bigfile.txt > $1)}' aaa