The many faces of awk

The many faces of awk

If you only use awk when you need to select a specific field from lines of text, you might be missing out on a lot of other services that the command can provide. In this post, we’ll look at this simple use along with some of the other things that awk can do for you and provide some examples.

Plucking out columns of data

The easiest and most commonly used service that awk provides is selecting specific fields from files or from data that is piped to it. With the default of using white space as a field separator, this is very simple.

$ echo one two three four five | awk ‘{print $4}’
$ who | awk ‘{print $1}’

White space is any sequence of blanks and tabs. In the commands shown above, awk is extracting just the fourth and first fields from the data provided.

To read this article in full, please click here

div#stuning-header .dfd-stuning-header-bg-container {background-image: url(;background-size: initial;background-position: top center;background-attachment: initial;background-repeat: no-repeat;}#stuning-header {min-height: 650px;}