$
Learn Linux handbook
en
XP:0
Quest 25Organizer
+240 XP

Sorting and Finding Uniques

Launch Interactive Terminal for This Quest→No installation required • Runs fully in browser

Concept & Overview

Imagine sorting a deck of cards where duplicates are scattered all over. To easily spot and remove duplicates, you'd first group the identical cards together. In Linux, the uniq command filters out repeating lines, but it has a catch: it only detects duplicates that are right next to each other!

- To remove all duplicates from a messy list, you must first sort the lines using sort and then pass the result to uniq. E.g., sort raw.txt | uniq organizes and cleans the list in one go.

Let's clean up a messy guest list. The file names.txt contains duplicate names. Connect sort and uniq with a pipe to find all unique names alphabetically, and save them in unique_names.txt.

Command Syntax Reference

Command / SyntaxDescription
sort names.txtSort lines of names.txt alphabetically
sort names.txt | uniq > unique_names.txtSort and filter duplicates into a file

Verification Objectives

These conditions will be automatically verified when you run commands inside the interactive terminal simulator:

  • ○
    Use the "sort" command on names.txt
  • ○
    Pipe sorted output into "uniq" command
  • ○
    Create file "unique_names.txt"
  • ○
    Verify content has unique sorted names

Ready to complete Quest 25?

Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.