Skip to Content

A stick figure smiling

Here's a preview from my zine, Bite Size Command Line!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
read the transcript!

panel 1:

awk is a tiny programming language for manipulating columns of data

person: I only know how to do 2 things with awk but it’s still useful!

panel 2: basic awk program structure

BEGIN {...}  
CONDITION (action}  
CONDITION (action}

(do action on lines matching CONDITION)

END {...}

panel 3: extract a column.of text with awk

awk -F, '{print $5}'
the comma is the column separator
the ‘ is a single quote!
{print $5} means print the 5th column

person: this is 99% of what I do with awk

panel 4:

SO MANY Unix commands print columns of text (ps! Is!)

so being able to get the column you want with awk is GREAT

panel 5: awk program example

sum the numbers in the 3rd column

{s += $3}; (action)
END {print s}' (at the end, print the sum!)

panel 6: awk program example

print every line over 80 characters
length($0) > 80
“length” is the condition

(there’s an implicit {print} as the action)

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)