March 2018
Beginner to intermediate
416 pages
9h 24m
English
As we have seen in the previous example, to add an empty space on the right side, we used a minus symbol (-) immediately after %. If we do not put any symbol after %, it makes the string right justified. The empty spaces are kept on the left side instead of the right.
For example, in the employee database emp.dat we print the first name of the employee again but this time using the right justified expression in printf with no symbol following the percentage % sign, as follows:
$ awk '{printf "|%10s|\n", $1 }' emp.dat
The output on execution of the preceding code is as follows:
| Jack|| Jane|| Eva|| Amit|| Julie|| Ana|| Hari|| Victor|| John|| Billy|| Sam|| Ginny|| Emily|| Amy|| Vina|
Read now
Unlock full access