回文章列表
作者demintree.bbs@ptt.cc (Mirabelli's back in tow) 看板: linux
標題Re: [問題] grep 能同時過濾 2個條件嗎
時間批踢踢實業 (2008/05/21 Wed 17:19:10)
※ 引述《cotix (Feb 14, 2007)》之銘言:
: 我想要用grep 指令,同時過濾「兩個條件」
: 比如說,我想抓出一行中,同時有提到 sta1 與 sta2 字眼,
: 但找了很久, 似乎文件都只提到單一條件
: 請問我的要求,grep可以滿足嗎...
你把grep的結果pipe給後面的grep不就滿足了嗎?
for example
ls -al|grep sta1|grep sta2

--
不過這不是最好的解答,在某些情形下你可能會找錯
找 同時存在"aba" "bac"
abac會符合,但我想這不是我們想要的
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.195.214
※ 編輯: demintree       來自: 140.113.195.214      (05/21 17:19)
文章選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻