I am trying to solve a problem in which I am given a few lines for eg:
abdkfsj | kfjlds | james
sdlfjk | sfdjsldfjk | andrew
sdjfsdl | dskljoer | james
I was asked to find the lines which contain james and print them in reverse order the output of above example will be-
james | kfjlds | abdkfsj
james | dskljoer | sdjfsdl
Can someone please tell me how to solve this and what command will be used to solve this question in unix using shell scripting?
Tried this:
awk -F"|" '{ print $3 $2 $1}' | grep --line-buffered james input.txt