Skip to content
Learn Netverks

Lesson

Step 17/36 47% through track

text-processing-bash

Text processing

Last reviewed Jun 1, 2026 Content v20260601
Track mode
none
Means
Read / quiz
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Text processing: the syntax, patterns, and safety habits you need before advancing in Bash.

Teams still ship Text processing in Bash codebases—skipping it leaves gaps in debugging and code reviews.

You will apply Text processing in contexts like: CI jobs, server maintenance, local dev automation, and Git hooks.

Read each lesson, copy bash examples into your own terminal, and complete the lesson MCQs—there is no in-browser runner for security reasons.

When you can explain the previous lesson's ideas without copying starter code.

Classic Unix tools—cut, sort, uniq, awk, sed—transform columnar and line-based text without loading a full language runtime.

cut, sort, uniq

printf "b\na\nb\n" | sort | uniq -c
printf "name:Ada\nage:30\n" | cut -d: -f2

uniq only collapses adjacent duplicates—sort first.

awk one-liner

awk -F, '{sum+=$2} END {print sum}' numbers.csv

-F, sets the field separator; END runs after all lines—typical for totals.

sed substitution

sed 's/error/ERROR/g' log.txt | head

s/old/new/g replaces globally per line—test on a sample before editing files in place (-i).

Important interview questions and answers

  1. Q: Why sort before uniq?
    A: uniq only removes consecutive duplicate lines.
  2. Q: awk vs Python?
    A: awk is great for quick column sums; Python wins for complex data structures.

Self-check

  1. What does uniq -c add?
  2. What sed expression replaces all occurrences on a line?

Tip: sort | uniq -c is interview bread-and-butter for log summaries.

Interview prep

sort before uniq?

uniq only removes adjacent duplicate lines.

awk role?

Column-oriented text processing.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • awk vs sed?
  • cut delimiter?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump