rev
Reverse lines of a file or files.
rev [FILE...]
The rev utility copies the specified files to the standard output, reversing the order of characters in every line. If no files are specified, the standard input is read.
Why use rev?
Let's say you want to get the name of all files of the configuration directory (etc).
find /etc/ -maxdepth 4 -type f -exec echo "{}" \;
Your first instinct might be to cut the last part of each line but that varies between file to file; sometimes it's the third position, the second or even the forth.
To fix this, use the rev
command to make the file on the last position, the first.
find /etc/ -maxdepth 4 -type f -exec echo "{}" \; | rev
Then, cut so only the first element is present using cut.
find /etc/ -maxdepth 4 -type f -exec echo "{}" \; | rev | cut -d"/" -f1
Finally, revert again so the order of the files is the same from the original list.
find /etc/ -maxdepth 4 -type f -exec echo "{}" \; | rev | cut -d"/" -f1 | rev
And there you have it! A list of files from a set of subdirectories._