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

Using the minus modifier (-) for left justification

In previous examples, the empty spaces were added on the left of the input string. However, this not the general output we use. To add the spaces to the right of the string, we have to make the string left justified. If the input string is less than the number of characters specified, we put a minus symbol (-) immediately after the %. This will print characters to the left and spaces will be added to the right.

For example, in the employee database emp.dat, we print the first name of the employee using a left-justified expression in printf, with a minus symbol immediately followed by a percentage % sign. To print each processed record in separate line, we append backslash n:

$ awk '{printf ...

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