[英]How can I count the amount of five letter words in a txt file using grep?
[英]How can I grep a file using OR
我想使用此字符串'foo'或此字符串'bar'搜索文件。 到目前為止,這是我嘗試過的:
cat filename.csv | grep foo\|bar
您可以使用多個-e
標志指定多個模式:
grep -e foo -e bar filename.csv
這是POSIX標准。
我先前建議的內容不適用於某些安裝。 我相信這是一種更可移植的語法:
grep -E 'foo|bar' filename.csv
上面是另一種形式:
egrep 'foo|bar' filename.csv
egrep支持使用正則表達式,在這種情況下為“ foo | bar”
將egrep與正則表達式一起使用。
cat filename.csv | egrep 'foo|bar'
您可以使用以下任何一種。
貓filename.csv | grep -E'foo | bar'
grep -E'foo | bar'filename.csv
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.