c++ - Reverse the data order -


suppose, have file (file.txt) contain few numbers characters.

1 2 3 4 (23)  23 2 1 (51)  2 1 4 (11) 

and, read in reverse order given below.

(23) 4 3 2 1  (51) 1 2 23  (11) 4 1 2 

i tried:

awk '{print $nf,$0}' file.txt | sort -nr 

is there command-line in linux or mini-code (in awk or in c++ or other language) perform task?

awk '{for (i=nf;i>0;i--){printf $i" "};printf "\n"}' file.txt 

output:

 (23) 4 3 2 1   (51) 1 2 23   (11) 4 1 2  

Comments