Reverse lines of a file.
Syntax: rev [file]
The rev utility copies the specified files to the standard output, reversing the order of characters in every line.
If no file is specified, the standard input is read (type CTRL-D to end).
The most common use of rev is to reverse the lines, apply a sort to the result and then pipe through rev a second time to restore the original.
Given the input of:
The quick brown fox
jumps over the lazy dog
Rev will output:
xof mworb kciuq ehT
god yzal eht revo spmuj
“The weirder you’re going to behave, the more normal you should look. It works in reverse, too. When I see a kid with three or four rings in his nose, I know there is absolutely nothing extraordinary about that person” ~ P. J. O’Rourke
Related linux commands:
sort – Sort text files (sort – k will sort on a key)