Reversing text order of each line of a file in UNIX

My input is:

hello how are you
my chemistry book is lost
what is up
etc...

And I want the output to be:

you are how hello
lost is book chemistry my
up is what
....

I found an earlier response to a similar question but it was not accurate as it required a certain string length for each line

perl -ne 'chomp;print join(" ",(reverse(split(/\s+/,$_)))),"\n";' filename
1 Like

With awk:

awk '{n=split($0,F); for(i in F) $i=F[n-i+1]}1' file