I have used the following command to get unique list of each name from my file
grep -oP "name_\w*" file_copy.txt | sort |uniq > list.txt
FILE=list.txt
while read line; do
cat file_copy.txt | grep "$line" | wc -l
cat file_copy.txt | grep $line | grep "name" | grep $line+1 -v | wc -l
Last command is not running the way i expected
list.txt files like below:
USA
Russia
Japan
file_copy.txt
USA Russia Russia Russia Japan
Japan Japan USA USA Russia
Japan Japan USA USA Russia
Japan Russia USA USA Russia