我需要计算包含单词the
和an
文本文件 ( poem.txt
) 的行,但不计算同时包含.
我试过使用
grep -c the poem.txt | grep -c an poem.txt
Run Code Online (Sandbox Code Playgroud)
但是这给了我6个错误的答案时的总数the
和an
是9行。
我确实想计算包含单词的行而不是单词本身。只有实际的单词应该算数,所以the
但不是there
,an
但不是Pan
。
示例文件: poem.txt
Where is the misty shark?
Where is she?
The small reef roughly fights the mast.
Where is the small gull?
Where is he?
The gull grows like a clear pirate.
Clouds fall like old mainlands.
She will Rise calmly like a dead pirate. …
Run Code Online (Sandbox Code Playgroud)