tac


tac

Purpose

Copy a file, line by line, to the standard output in reverse order (last line first).

Syntax

tac file

Options

-b places the separator at the beginning of each line.

-r treats the separator string specified by -s as a regular expression.

-s sep specifies a separator (instead of the default newline character).

Description

The tac command displays the specified text file in reverse order, copying the lines to standard output in reverse order. By default, tac treats each line as a record and uses the newline character as the record separator. However, you can specify a different separator character, in which case tac copies those records to standard output in reverse order.