grep/awk/sed的多条件查询

发表于:2007-05-26来源:作者:点击数: 标签:

grep/awk/sed的多条件查询

# cat gt
one two three
four five six
one two
one seven three
# grep one three gt
grep: three: No such file or directory
gt:one two three
gt:one two
gt:one seven three

截取同时出现one和three的行,结果应该是:
one two three
one seven three

1. 用grep
cat gt | grep one | grep three
2. 用awk
awk '/one/&&/three/' gt
3. 用sed
sed -ne '/one/' gt
完毕

原文转自:http://www.ltesting.net