grep 能同時過濾 2個條件嗎 - Linux

By Ina
at 2008-05-21T17:15
at 2008-05-21T17:15
Table of Contents
※ 引述《cotix (Feb 14, 2007)》之銘言:
: 我想要用grep 指令,同時過濾「兩個條件」
: 比如說,我想抓出一行中,同時有提到 sta1 與 sta2 字眼,
: 但找了很久, 似乎文件都只提到單一條件
: 請問我的要求,grep可以滿足嗎...
你把grep的結果pipe給後面的grep不就滿足了嗎?
for example
ls -al|grep sta1|grep sta2
--
不過這不是最好的解答,在某些情形下你可能會找錯
找 同時存在"aba" "bac"
abac會符合,但我想這不是我們想要的
--
: 我想要用grep 指令,同時過濾「兩個條件」
: 比如說,我想抓出一行中,同時有提到 sta1 與 sta2 字眼,
: 但找了很久, 似乎文件都只提到單一條件
: 請問我的要求,grep可以滿足嗎...
你把grep的結果pipe給後面的grep不就滿足了嗎?
for example
ls -al|grep sta1|grep sta2
--
不過這不是最好的解答,在某些情形下你可能會找錯
找 同時存在"aba" "bac"
abac會符合,但我想這不是我們想要的
--
Tags:
Linux
All Comments

By Wallis
at 2008-05-23T09:30
at 2008-05-23T09:30

By Rebecca
at 2008-05-25T04:13
at 2008-05-25T04:13

By Wallis
at 2008-05-28T01:09
at 2008-05-28T01:09
Related Posts
grep 能同時過濾 2個條件嗎

By Valerie
at 2008-05-21T16:46
at 2008-05-21T16:46
在NB上裝LINUX...

By Bennie
at 2008-05-21T16:36
at 2008-05-21T16:36
辦公室用途 請給建議

By Kristin
at 2008-05-21T15:13
at 2008-05-21T15:13
cpu使用率顯示不到10% 可是溫度很高...

By Tracy
at 2008-05-21T13:38
at 2008-05-21T13:38
顯卡安裝.......

By Genevieve
at 2008-05-21T12:23
at 2008-05-21T12:23