tac

December 12, 2014 ยท View on GitHub

cat reversed line-wise.

Coreutils.

[ "$(printf "a\nb\n" | tac)" = "$(printf "b\na")" ] || exit 1

Things get messy if the input does not end in newline:

[ "$(printf "a\nb" | tac)" = "$(printf "ba")" ] || exit 1