I tried to execute below command:
ls -ltr | awk \'BEGIN { print \"File\\t\\t\\tOwner\"} { print $9,\"\\t\",$3} END {print \"-DONE \\n\"}\'
and
You need to use padding except for the last column. Since you have only 2 columns, the first will be enough.
When you use printf
instead of print
, you can print all the variables based on a template. The following examples print a string (%s
) with a padding (24
) on the right side (-24
), so it becomes %-24s
.
ls -ltr | awk 'BEGIN {printf "%-24s%s","File","Owner"} { printf "%-24s%s\n",$9,$3} END {print "-DONE \n"}'
For more information you can check this or this.