[英]How do I grep for all words that are more than 6 characters and without any vowel letters?
[英]How do I get the words without these characters?
我只想從文本文件1.txt
獲取不包含字母a
, b
和c
的單詞,並將其導出到2.txt
,但這不會返回任何內容:
grep -o [^abc]*$ 1.txt > 2.txt
如何獲得不包含a
, b
和c
的單詞?
使用GNU grep,您可以使用
grep -w -o '[^abc]*' 1.txt > 2.txt
man
的相關作品是:
-w, --word-regexp
Select only those lines containing matches that form whole words...
-o, --only-matching
Print only the matched (non-empty) parts of a matching line...
嘗試這個:
grep -w -o -P '[^abc\s]*' 1.txt > 2.txt
因此,在“單詞”中間也不允許使用空格。
我也僅包括了-P標志,以便將正則表達式解釋為Perl並允許\\ s占位符。
-P, --perl-regexp
Interpret PATTERN as a Perl regular expression.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.