小编Coo*_*iot的帖子

如何计算包含两个单词之一但不包含两个单词的行

我需要计算包含单词thean文本文件 ( poem.txt) 的行,但不计算同时包含.

我试过使用

grep -c the poem.txt | grep -c an poem.txt
Run Code Online (Sandbox Code Playgroud)

但是这给了我6个错误的答案时的总数thean是9行。

我确实想计算包含单词的行而不是单词本身。只有实际的单词应该算数,所以the但不是therean但不是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)

grep awk text-processing

5
推荐指数
3
解决办法
1068
查看次数

标签 统计

awk ×1

grep ×1

text-processing ×1