tac

Concatenate multiple files and print line-by-line reverse to standard output.

Summary

tac [OPTION]... [FILE]...

The main purpose

Parameters

FILE (optional): The file to be processed, which can be one or more.

Options

Long options are equivalent to short options

-b, --before Concatenate delimiters before rather than after.
-r, --regex Treat delimiters as base regular expressions (BRE).
-s, --separator=STRING Use STRING as the separator instead of the default newline character.
--help Display help information and exit.
--version Display version information and exit.

return value

The return status is success unless illegal options or illegal parameters are given.

example

# Example selected from the official info document:
# Reverse a file character by character:
tac -r -s 'x\|[^x]' test.log

# About the -b option:
seq 1 3 |tac
# output
3
2
1
# Use the -b option:
seq 1 3 |tac -b
# Output, note that there is no newline character after 21:


3
twenty one
# The previous example is equivalent to converting '1\n2\n3\n' to '3\n2\n1\n'
# The previous example is equivalent to converting '1\n2\n3\n' to '\n\n3\n21'

Notice