0
0
Linux CLIscripting~15 mins

sort and uniq in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Sort and Uniq Command Practice
📖 Scenario: You have a list of fruit names with some duplicates. You want to organize this list by sorting it alphabetically and removing duplicates to get a clean list.
🎯 Goal: Learn how to use the sort and uniq commands together to sort a list and remove duplicate entries.
📋 What You'll Learn
Create a file named fruits.txt with the exact fruit names given.
Use the sort command to sort the fruit names alphabetically.
Use the uniq command to remove duplicate fruit names after sorting.
Display the final sorted and unique list on the terminal.
💡 Why This Matters
🌍 Real World
Cleaning and organizing lists of data like names, products, or logs is common in daily computer tasks.
💼 Career
Many IT and data jobs require sorting and filtering text data quickly using command line tools.
Progress0 / 4 steps
1
Create the fruits.txt file
Create a file named fruits.txt containing these exact lines in this order: apple, banana, apple, orange, banana, grape.
Linux CLI
Need a hint?

Use echo with -e and newline characters \n to create the file.

2
Sort the fruits.txt file
Use the sort command on fruits.txt and save the output to a new file called sorted_fruits.txt.
Linux CLI
Need a hint?

Use sort fruits.txt > sorted_fruits.txt to save sorted output.

3
Remove duplicates with uniq
Use the uniq command on sorted_fruits.txt and save the output to a new file called unique_fruits.txt.
Linux CLI
Need a hint?

Use uniq sorted_fruits.txt > unique_fruits.txt to remove duplicates.

4
Display the final unique sorted list
Use the cat command to display the contents of unique_fruits.txt on the terminal.
Linux CLI
Need a hint?

Use cat unique_fruits.txt to show the final list.