Bash & Linux·Bash from first command to automation

Text processing

Search, cut, sort and transform text with grep, cut, sort and awk.

Beginner 14 min read Lesson 5 of 300 Challenge included
What you will be able to do
  • Use grep -i for case-insensitive search.
  • Use cut -d and -f for delimited fields.
  • Use sort then uniq -c for counts.
  • Use awk for field-based reports.

In plain English

Most operations work is text. grep finds lines, cut extracts columns, sort orders them, uniq removes duplicates and awk handles fields and arithmetic. Learn the five and you stop opening a spreadsheet for simple questions.

terminalTerminal
printf 'css,18\nhtml,12\ncss,22\n' > minutes.csv
cut -d, -f1 minutes.csv | sort | uniq -c
awk -F, '{ total += $2 } END { print total }' minutes.csv
Your turn

Sum a column

Medium

Sum the second comma-separated column of minutes.csv using awk.

BASH · starter
awk
Check your understanding before moving on.
Knowledge checkQuestion 1

Which command counts duplicate lines after sorting?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Processes
Lesson 5 of 300 · 0% of course