I am trying to write a quick awk script that converts lines in this format:
AAAA BBBB CCCC DDDD...
to
CCCC AAAA BBBB DDDD...
This is my script:
{ printf "%s %s %s %s", $3, $1, $2, $4 };
This works fine except when the original input line has more than 4 tokens, in which case the 5th and following tokens are not printed.
I checked some answers, like Using awk to print all columns from the nth to the last but they rely on setting variables to ""
which seems to cause problems if those variables are reused later.
Is there an easy way to replace $4
by something like "the substring from $4 until the end of the line"?