#157 Formatting output in awk
Without formatting, the command look like this
awk ' BEGIN {FS=":"} { print $1,$3,$7 } ' /etc/passwd
The same command with formatting
awk ' BEGIN {FS=":"} { printf "%10s %4d %17s\n",$1,$3,$7 } ' /etc/passwd
With the header information added to the BEGIN block:
awk ' BEGIN {FS=":" ; print "%10s %4s %17s\n","Name","UID","Shell"} { printf "%10s %4d %17s\n",$1,$3,$7 } ' /etc/passwd
Recent Comments