0

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 
Dexter
  • 3
  • 2
  • I have put an answer here: http://stackoverflow.com/a/39316690/2361131 that takes care of reading from file (unlike the other answers of the "duplicate question") – gawkface Sep 04 '16 at 12:03

1 Answers1

1
awk '{for(i=NF;i>=1;i--) if(i!=1)printf $i" ";else print $i}'
world hello
bash world hello
P....
  • 17,421
  • 2
  • 32
  • 52
  • its work...!!! need one more help.. what if there is one file having multiple values and number and have to grep or add that value into string i.e cat file abc xyz mno qat 8 9 1 vvv sss df 23 45 66 in this above file how do i add last three numbers in string – Dexter Aug 31 '16 at 09:27
  • 1
    Not able to understand what you are asking. You can ask your query as another question with sample input and expected output. SO people will help you. Make sure you have googled it before putting it here. Thanks. – P.... Aug 31 '16 at 09:29