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

Record separator

The record separator (RS) defines the input RS for AWK and its default value is set as a single new line. As with other AWK variables, we can redefine the RS as a new value. While defining the new input RS, it needs to be enclosed in quotation marks as a string constant in the BEGIN block. For example, let us set the new input record separator as a single dot (.) for the employee database emp.dat file as follows:

$ awk 'BEGIN { RS="."}{ print}' emp.dat

The output of the execution of this code is as follows:

Jack Singh 9857532312 jack@gmailcom M hr 2000Jane Kaur 9837432312 jane@gmailcom F hr 1800Eva Chabra 8827232115 eva@gmailcom F lgs 2100Amit Sharma 9911887766 amit@yahoocom M lgs 2350Julie Kapur 8826234556 julie@yahoocom ...

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