$
Linux Practice
Practice
Tutorials
English
한국어
日本語
中文
terminal
Welcome to Linux Practice Terminal!
Type "help" to see available commands.
user
@linux:
~
$
sort & uniq
Reset Lesson
Learn to sort text and remove duplicates with sort and uniq commands.
Step 1
Sort the names.txt file alphabetically.
Type: sort documents/names.txt
sort documents/names.txt
Step 2
Sort names.txt in reverse order using the -r flag.
Step 3
Try numeric sort with -n flag. Even with text, see how it behaves differently.
Step 4
Use uniq to remove consecutive duplicate lines. Note: uniq only removes adjacent duplicates!
Step 5
Combine sort and uniq with a pipe to get truly unique names.
Step 6
Use uniq -c to count how many times each name appears.