shell - grep - awk - sed的多条件查询
grep/awk/sed的多条件查询
2004-04-23 15:18 pm来自:Linux文档
现载:Www.8s8s.coM
地址:无名
# 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/{/three/p}' gt
完毕