O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Matching whitespaces

Whitespaces matches anything that is considered a whitespace character. It is equivalent to  '[[:space:]]'.

For example, in the gopr.txt file, we match all the lines that contain 'e' followed by whitespace and 'd' using the '\s' operator. It will print all the lines in which there is a space or tab between 'e' and 'd', as follows:

$ awk '/e\sd/'  gopr.txt

The output on execution of the preceding code is as follows:

e de    d

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required