1. Home
  2. Docs
  3. Beginning UNIX on Raven
  4. Answers
  5. Answers to wc, sort and uniq exercises

Answers to wc, sort and uniq exercises

1. How many files are there in our ~/files directory?

Answer: 15

Command: ls ~/files | wc -l

2. How many unique lines are in the song American Pie?

Answer: 94

Command: sort americanpie.txt | uniq | wc

3. Can you return a table of repeated lyrics with counts of their frequency, sorted in ascending order of duplication?

sort americanpie.txt | uniq -c | sort -n | grep -v 1