Can grep
pick lines if at least one element from a list of words appeared? For example
grep "hello开发者_如何学Go world" file1
grep
must give me all lines which have either the word hello
or the word world
or both of them.
grep "hello\|world" file1
put your patterns in some file patterns.txt, one pattern per line, and run
grep -Ff patterns.txt file1
How about
grep -r "hello\|world" file1
That's a recursive grep
by the way. It searches recursively for the term "hello world" in file1. It can also apply to a directory like so:
grep -r "hello\|world" dir/dir2/
Try this,
echo "hello world "| grep -o "\bworld\b"
output is
world
or
grep -E 'hello|world' filename
精彩评论