You don't need the for
loop. You can pass the *.tsv
glob to grep
and it will search in all of those files. If you pass the option -f pattern.txt
to grep
it will search for all patterns in pattern.txt
.
The following command should do the whole work:
grep -n -f pattern.txt *.tsv | cut -f 1,2,3 >> Results_File.lst
Check man grep
for further explanation of grep
and it's options.