I have two files: $ cat File1ABC$ cat File2A aaa BD bbb AB aaa hI would like to search patterns from File1 into File2, a sort of what grep -f File1 File2 would do, but searching the patterns reported in File1 only in $1 of File2Sample output:$cat File3A aaa BB aaa h
grep patterns from file1 into column of file2
text processing;grep
With awk:awk 'NR==FNR{a[$0]=NR; next} a[$1]' f1.txt f2.txtNR==FNR{a[$0]=NR; next}: for first file (f1.txt) we are putting the record as key to an assiciative array with the corresponding record number as the valuea[$1]: for second file (f2.txt), the record is only printed if the first field is a key of array aExample:% cat f1.txt                                       ABC% cat f2.txt                                       A aaa BD bbb AB aaa h% awk 'NR==FNR{a[$0]=NR; next} a[$1]' f1.txt f2.txtA aaa BB aaa h