Given tabular output from some program in bash I would like to change order of colums printed. Assume number of columns might vary.
Sample input
Name Surname Age
Oli Aaa 15
Boa Bbb 25
Expected output
Age Surname Name
15 Aaa Oli
25 Bbb Boa
What I tried
It seems to me as an easy task when number of columns is known, but I don't know what to do when number of columns is just N. For 3 columns simple AWK script would do:
cat table.txt | awk '{print $3 $2 $1}' > reversed_table.txt
It would be good to achieve this using only POSIX-compliant tools.