![grep 有什麼比 ack 更好的嗎?](https://rvso.com/image/1413934/grep%20%E6%9C%89%E4%BB%80%E9%BA%BC%E6%AF%94%20ack%20%E6%9B%B4%E5%A5%BD%E7%9A%84%E5%97%8E%EF%BC%9F%20.png)
ack
我不久前開始使用,它很棒,但仍然引出了一個問題:
還有什麼東西grep
嗎做得更好比ack
?
或者也許有什麼東西grep
可以做到這一點ack
不能做?
答案1
您應該查看手冊頁,它會告訴您:
WHEN TO USE GREP
ack-grep trumps grep as an everyday tool 99% of the time, but don't
throw grep away, because there are times you'll still need it.
E.g., searching through huge files looking for regexes that can be
expressed with grep syntax should be quicker with grep.
If your script or parent program uses grep "--quiet" or "--silent" or
needs exit 2 on IO error, use grep.
答案2
ack
不是所有 Linux/Unix 伺服器上預設安裝的一部分,但grep
確實如此。您是否嘗試過 the_silver_searcher 或 the_platinum_searcher。他們都跑得比ack
答案3
如果您正在搜尋二進位文件,那麼您必須使用 grep,因為 ack 總是會忽略它們。
當搜尋幾個大檔案時,grep 會比 ack 更快。
聽起來您正在嘗試決定是否應該放棄 grep 並一直使用 ack,我建議您不要這樣做。在適當的時候,您應該同時使用 grep 和 ack。基本上,ack 用於搜尋原始程式碼,grep 用於通用搜尋。