How to reverse the output of the grep command?

Viewed 11915

i have one problem with grep command. in my called script i use:

   "ServicePassword":fooooooooooo
   "ServiceUserName":barrrrrrrrr
grep -E '"ServiceUserName"|"ServicePassword"' >> user.txt

but in user.txt file i will get first "ServicePassword":fooooooooooo then "ServiceUserName":barrrrrrrrr How can i use grep command to reverse it to get first ServiceUserName then ServicePassword output in user.txt file ? I need it only this sequence. i try to change:

grep -E '""ServicePassword""|"ServiceUserName"' >> user.txt

and nothing.... maybe exist a better solution?

4 Answers

Use tac (opposite of cat)

grep -E '"ServiceUserName"|"ServicePassword"' | tac >> user.txt
Related