2
rated 0 times
[
2]
[
0]
/ answers: 1 / hits: 1200
/ 1 Year ago, wed, march 22, 2023, 2:31:47
I can search for files which have a specific word by using grep
grep -l "word" /path
However what if I want to search for files which have "word 1" and "word 2" in a same line? I can use:
mkdir new;for i in * do;grep "word 1" $i > new/$i_new;done
then use
grep -l "word 2" /new
But I would like to have a one line command. Using
egrep -w -R 'word 1|word 2' /path
only search for lines have "word 1" OR "word 2".
What if I have "word 3", "word 4"?
More From » grep