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

Escape sequences

When using regular expressions and strings, certain characters cannot be included literally in string constants ("hello") or regular expression constants (/hello/). To specify the characters for which there may not be other notations, they are represented as escape sequences. Escape sequences begin with a backslash ('\'). For example, it can represent that an \n newline character is used, which otherwise cannot be represented in strings or regular expressions. Similarly, \b stands for backspace, \t stands for tab, and \/ represents a forward slash. They are quite useful in generating formatted output.

For example, to insert a new line after each line of the emp.dat file, we can use the \n escape sequence, as follows:

$ awk ...

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