- 使用常见的 grep 命令实现
- 可以用 man grep 查看grep使用说明
Matcher Selection
-F, --fixed-strings, --fixed-regexp
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by POSIX, --fixed-regexp is an obsoleted alias, please do not use it in new scripts.)
Matching Control
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is specified by POSIX.)
-v, --invert-match
Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.)
a差b
grep -F -v -f b.file a.file
cat a.file | grep -F -v -f b.file
a交b
grep -F -f a.file b.file
cat b.file | grep -F -f a.file
a并b
cat a.file b.file | sort | uniq
网友评论