All TILs
linux·

cat spelled backwards

using tac to reverse a file line by line

we can use tac to print a file with its lines in reverse order.

e.g: for log files which we care about the most recent entries, we can use tac.

print the whole log file in reverse order.

tac tmp/app.log

print 5 most recent log entries.

tac tmp/app.log | head -5

← All TILsMay 28, 2026