🖥️tac
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the tac command with important options and switches using examples.
3 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ████████╗ █████╗ ██████╗
# ╚══██╔══╝██╔══██╗██╔════╝
# ██║ ███████║██║
# ██║ ██╔══██║██║
# ██║ ██║ ██║╚██████╗
# ╚═╝ ╚═╝ ╚═╝ ╚═════╝
# tac: Concatenate and write files in reverse
# tac copies each file (‘-’ means standard input), or standard input if none are given, to standard output, reversing the records (lines by default) in each separately.
# Records are separated by instances of a string (newline by default). By default, this separator string is attached to the end of the record that it follows in the file.
tac [option]… [file]…
# The program accepts the following options. Also see Common options.
# The separator is attached to the beginning of the record that it precedes in the file.
-b --before
# Treat the separator string as a regular expression.
-r --regex
# Use separator as the record separator, instead of newline. Note an empty separator is treated as a zero byte. I.e., input and output items are delimited with ASCII NUL.
-s separator --separator=separator
# On systems like MS-DOS that distinguish between text and binary files, tac reads and writes in binary mode. An exit status of zero indicates success, and a nonzero value indicates failure.
# Example:
# Reverse a file character by character.
tac -r -s 'x\|[^x]'
tac 35.txt
# This command is very interesting which prints the content of a text file in reverse order, i.e., from last line to first line.
tac temp.txt > pmet.txt
# Reverse the order of the lines in a file using 'tac' (cat reverse) command
tac|tac|
# If you like pasting into STDIN pipeline, this trick can prevent the processing from starting until you press [Ctrl-D].
tac -s "^[[H"
# You can reverse a set of "records" using tac with the -s option and a record separator. Used to make globe spin backwards.
tac myfile.txt > /tmp/temp; echo "my line" >> /tmp/temp; tac /tmp/temp > myfile.txt
# Insert a line at the top of a text file without sed or awk or bash loops
# Yet another way to add a line at the top a of text file with the help of the tac command (reverse cat).
#==============================##==============================#
# CMD TAC #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command tac in a clear format. This allows users to quickly access the needed information for tac without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for tac are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.