您的位置:首页 > 文档 > Shell >
 文章分类 

grep/awk/sed的多条件查询


创建:2005-10-26 00:49:43
作者:Unlinux
来自: http://www.Unlinux.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

完毕

转载自:http://www.unlinux.com/doc/shell/20051026/111.html

评论】 【加入收藏夹】 【 】 【打印】 【关闭
 *  请尊重我们的劳动,转载请注明出自UnLinux.Com及作者名 * 

※ 相关链接
无相关信息
Copyright © 2005 UnLinux.Com All Rights Reserved