grep -f file to print in order as a file
问题 I have a a requirement to grep patterns from a file but need them in order. $ cat patt.grep name1 name2 $ grep -f patt.grep myfile.log name2:some xxxxxxxxxx name1:some xxxxxxxxxx I am getting the output as name2 was found first it was printed then name1 is found it is also printed. But my requirement is to get the name1 first as per the order of patt.grep file. I am expecting the output as name1:some xxxxxxxxxx name2:some xxxxxxxxxx 回答1: You can pipe patt.grep to xargs , which will pass the