Sorting & Deduplicating Data (sort, uniq, cut)
Turn raw text into clean, ordered data. Learn to sort lines, remove duplicates with uniq, and extract columns with cut, then chain them in pipelines.
Sorting & Deduplicating Data (sort, uniq, cut) is a free DevOps Bootcamp lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Shaping Text Data
Log files and CSVs are just lines of text. Three classic tools shape them: sort orders lines, uniq removes duplicates, and cut extracts columns.
Basic Sorting
sort orders lines alphabetically by default and prints the result.
sort names.txtNumeric Sorting
Plain sort treats numbers as text (10 before 2). Use -n for true numeric order and -r to reverse.
sort -n sizes.txt
sort -nr sizes.txt # largest firstSorting by a Field
Use -k to sort by a specific column and -t to set the delimiter.
sort -t: -k3 -n /etc/passwd # by UIDRemoving Duplicates with uniq
uniq collapses adjacent duplicate lines. It only works on sorted input, so it is almost always paired with sort.
sort access.log | uniqCounting Occurrences
uniq -c prefixes each line with how many times it appeared — perfect for frequency analysis.
sort ips.txt | uniq -cFinding Top Items
Combine sort, uniq -c, and another sort to rank items by frequency — a one-line "top N" report.
sort ips.txt | uniq -c | sort -nr | head -5Extracting Columns with cut
cut pulls fields from each line. Use -d for the delimiter and -f for the field numbers.
cut -d, -f1,3 data.csv # 1st and 3rd columnsCutting by Character
cut -c extracts character ranges by position, useful for fixed-width data.
cut -c1-8 dates.txt # first 8 charsUnique vs Duplicate Lines
uniq -d shows only lines that repeat, while uniq -u shows only lines that appear exactly once.
sort orders.txt | uniq -d # repeated onlyBuilding a Pipeline
The real power is chaining: extract a column, sort it, then count uniques to summarize a dataset in one command.
cut -d, -f2 sales.csv | sort | uniq -c | sort -nrQuick Check
Test your understanding.
Recap
You learned to shape data with sort (alphabetic, numeric -n, by field -k), uniq (dedupe adjacent lines, -c count, -d/-u), and cut (fields with -d/-f, characters with -c) — chained into powerful pipelines.
Frequently asked questions
Is the “Sorting & Deduplicating Data (sort, uniq, cut)” lesson free?
Yes — the full text of “Sorting & Deduplicating Data (sort, uniq, cut)” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.
What will I learn in “Sorting & Deduplicating Data (sort, uniq, cut)”?
Turn raw text into clean, ordered data. Learn to sort lines, remove duplicates with uniq, and extract columns with cut, then chain them in pipelines. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Sorting & Deduplicating Data (sort, uniq, cut)” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Advanced Text Manipulation (sed, awk)
- Archiving and Compression (tar, gzip, unzip)
- Disk Usage & System Info (df, du, uname)
- Sorting & Deduplicating Data (sort, uniq, cut)