shell - How do I grep for multiple patterns? - Unix & Linux Stack Exchange
The portable way is to use the newer syntax, extended regular expressions. You need to pass the -E option to grep to select it. On Linux, you can also type egrep instead of grep -E (on other unices, you can make that an alias).
grep -E 'foo|bar' *.txt Another possibility when you're just looking for any of several patterns (as opposed to building a complex pattern using disjunction) is to pass multiple patterns to grep. You can do this by preceding each pattern with the -e option.
grep -e foo -e bar *.txtRead full article from shell - How do I grep for multiple patterns? - Unix & Linux Stack Exchange
No comments:
Post a Comment