How do I combine two grep commands?

How do I combine two grep commands?
Answer
Two possibilities:
  1. Group them: { grep ‘substring1’ file1.txt grep ‘substring2’ file2.txt } > outfile.txt. …
  2. Use the appending redirection operator >> for the second redirection: grep ‘substring1’ file1.txt > outfile.txt grep ‘substring2’ file2.txt >> outfile.txt.
 

Tìm kiếm

Back
Top