How to reverse lines of a text file?
There is a standard command for your purpose:
tail -r file.txt
prints the lines of file.txt in reverse order!
Answer is not 42 but tac
.
Edit: Slower but more memory consuming using sed
sed 'x;1!H;$!d;x'
and even longer
perl -e'print reverse<>'