I would like a command line incantation to reverse the field order of arbritrary length text records. Solutions provided in Rearrange columns using cut and Elegant way to reverse column order don't solve this issue since they assume a fixed amount of fields, though maybe they would with minor changes.
Sort of like the tac
command that exhibits reverse cat
functionality. I'd like what the ohce
command would do (if it existed) to reverse echo
functinality.
For example:
a b c d
e f
g h i
Should be transformed to
d c b a
f e
i h g
Using
datamash
:Output:
Unlike
rev
, it doesn't reverse words:Output:
Using awk:
There's a command to do it, it's named
rev
from util-linux :or using perl :
But like you explain in the comments, if you want the 3 latest columns, you can use awk :
with bash: