Dexter Dexter - 3 months ago 13
Linux Question

read line reverse from a file

how do I read line reverse from a file like,

#cat file
hello world
hello world bash


so I need output like this,

world hello
bash world hello

Answer
awk '{for(i=NF;i>=1;i--) if(i!=1)printf $i" ";else print $i}'
world hello
bash world hello