🖥️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.

▁ ▂ ▃ ▄ ꧁ 🔴☠ 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						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░