根据用户输入计算重复行而不显示某些信息

Counting duplicate lines based on user input without showing certain information

你好,我得到了这个短代码,我想用它来计算重复行的数量,但我只希望显示该数字

文件的输入

 The Hunger Games:Suzanne Collins:1:1:1
 The Hunger Games:test:1:1:1

期望的输出

 found: 2    

下面代码的输出

 found: 2 The Hunger Games

使用过的代码

 echo "Title: "
 read title
 record=$(grep -io "$title" BookDB.txt | sort | uniq -c)
 echo "found: " $record

您可以使用 awkcut

Awk

 echo "found: " $record | awk '{print   }'

剪切

 echo "found: 2 The Hunger Games" | cut -f1-2 -d" "

测试

$ echo "found: " $record | awk '{print   }'
found: 2
$ echo "found: 2 The Hunger Games" | cut -f1-2 -d" "
found: 2