Stage 3 · Lesson 7 of 8
Columns with awk
reads text one line at a time and splits each line into fields: $1 is the first, $2 the second, and so on. By default it splits on spaces; -F lets you choose another separator, such as a comma. That makes awk the quick tool for working with columns.
awk '{print $1}' access.log prints the first field of every line. awk -F, '$3 > 100' data.csv keeps only the rows where the third column is above 100. It can add up and count too: { total += $2 } END { print total } sums the second column. A small part of awk is enough to be productive.
Common trapwriting whole programs in awk when a short script would be clearer.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CourseFreeThe Missing Semester of Your CS Education
MIT · Beginner
The data wrangling lecture walks through grep, sed, awk and regular expressions on real logs
- BookFreeThe Linux Command Line
William Shotts · Beginner
Clear chapters on text processing, regular expressions and searching for files