
我試圖讓 Grep 列印 txt 檔案中不包含數字 834 的所有行。
答案1
嘗試
grep -v '[834]' file
從man grep
-v, --invert-match
Invert the sense of matching, to select non-matching lines. (-v
is specified by POSIX.)
答案2
您要求 grep 列印包含非 8、3 或 4 字元組成的模式的所有行。若要顯示「除」之外的所有內容,grep 具有 -v 開關。例如 grep -v "8\|3\|4" 之類的東西應該可以工作。或者,如果您特別想扔掉數字 834:grep -v 834