
我經常使用這樣的命令
find . ! -iname "*test*" -o -iname "*foo*" | xargs zgrep -ie first.*last -e last.*first
我使用是zgrep
因為它能 grep
透過.gz
文件,如果文件沒有被 gzip 壓縮,它只會使用grep
.然而我經常得到
gzip: copy.txt.gz: No such file or directory
日誌使我的搜尋輸出變得混亂。有什麼辦法可以讓這些gzip
日誌靜音嗎?
答案1
您可以將命令標準錯誤輸出重新導向到空設備。
find . ! -iname "*test*" -o -iname "*foo*" | xargs zgrep -ie first.*last -e last.*first 2>/dev/null