tac
Print files in reverse line order
TLDR
Reverse lines of a file
SYNOPSIS
tac [options] [file...]
DESCRIPTION
tac concatenates and prints files in reverse, line by line. The name is "cat" spelled backwards, reflecting its reversed functionality.
By default, tac uses newline as the record separator, reversing line order. Custom separators can be specified, making it useful for reversing records in various file formats.
The tool is handy for viewing log files (newest first), reversing sorted output, or processing data that needs to be in reverse order.
PARAMETERS
-b, --before
Attach separator before instead of after record.-r, --regex
Interpret separator as regular expression.-s string, --separator= string
Use string as separator instead of newline.--help
Display help information.--version
Display version information.
CAVEATS
Reads entire input into memory (inefficient for very large files). Binary files may produce unexpected results. Regex separators may have performance impact. Does not reverse characters within lines.
HISTORY
tac is part of GNU coreutils, following the Unix tradition of tools that reverse operations (like rev which reverses characters). The name playfully reverses "cat". It provides functionality not available in standard Unix, though some BSD systems have alternatives.
