Need Help With Question for Beginner Linux Class

jhericurljuice

New Member
Credits
0
Morning everyone. I'm sort of stuck on this last question for this week's lab in my beginner's Linux class. It is entirely possible this question is going just right over my head, but hopefully you guys can help lead me on the right track since I'm still fairly new to all of this.

Here is the question:

Each line in tr_edits.txt now contains a single word. The lines are ordered in the same order as the words appeared in usdeclar.txt.. We want to find the 10 most frequently used words.
You need to count the number of duplicate words in tr_edits.txt using sort and uniq in combination.
You want to show a descending count of duplicate lines; i.e. most frequest first.
  • The command chain should look like
'<cmd1> tr_edits.txt | < cmd2> | < cmd3> > answer.txt'
NOTE: You need to figure out the commands and command options to use for cmd1, cmd2 and cmd3. See slide "Useful sort/uniq examples" for hints.

Now I'm probably way off, but I have come up with the following:

sort -u tr_edits.txt | uniq -c | sort -n -r > answer.txt
or
sort -u tr_edits.txt | uniq -c | sort -nr > answer.txt

Thanks for help in advance
 


Rob

Administrator
Staff member
Credits
14
Hey there - welcome to Linux.org! Just take out the -u on your sort command.

For example, try sort -u tr_edits.txt vs sort tr_edits.txt by themselves so you can see the difference. The -u is telling sort to only show each occurrence of each word just once.
 


Members online


Top