I am trying to use a simulated "and" statement with egrep. Currently I have egrep -i 'name.*policy' which works only if the order of appearance is true. Alternatively, I can egrep -i 'name.*policy|policy.*name' . I want to see if there is a better way to use an "and statement that is not order specific.
Asked
Active
Viewed 161 times
1 Answers
1
grep -P '(?=.*policy)(?=.*name)'
-
Thank you, unfortunately in my version of BSD, the -P option doesn't work. – Steve Mar 21 '17 at 18:08
grep name | grep policy
– ctx Mar 21 '17 at 17:34