commands

tac — reverse line order

Print records in reverse order, normally newline-separated; does not reverse characters. GNU -s changes the separator. Example assumes a fresh text-streams lab fixture.

Formal Syntax & Structure

linux syntaxlinux
tac [OPTION]... [FILE]...

Parameters & Attributes

NameTypeDescription
-soptionRecord separator
FILEoperandInput file

Return Value

exit status and output

GNU tac writes records in reverse order and returns nonzero on read/write errors. Empty input can produce empty output successfully; record reversal is not character reversal.

Working Example

Example Snippetlinux
tac events.txt
Linux Reference