The next challenge asks us to find a word that occurs exactly once in the data.txt file. We can accomplish this using sort and uniq. We cat the data file and pipe the results to sort, which doesn’t need any switches. We then pipe the sorted strings to uniq and give the command the -c switch, which prefixes the string with the number of times that string is present. Finally, we use grep to look for the line with a count of one.

bandit8@bandit:~$ cat data.txt | sort | uniq -c | grep "1 "
      1 XXXXXXXXXXXXXXXXXXXXX (actual password not shown)
bandit8@bandit:~$