-
-
Notifications
You must be signed in to change notification settings - Fork 1
Linux tac Guide
Mattscreative edited this page Dec 5, 2025
·
3 revisions
Complete beginner-friendly guide to tac on Linux, covering Arch Linux, CachyOS, and other distributions including reversing file output, line reversal, and reverse file display.
Basic usage:
# Reverse file
tac file.txt
# Displays file in reverse orderPipe input:
# Reverse from input
cat file.txt | tac
# Reverses piped inputReverse lines:
# Reverse lines
tac file.txt
# Last line first, first line lastReverse multiple:
# Multiple files
tac file1.txt file2.txt
# Reverses each fileSet separator:
# Custom separator
tac -s "---" file.txt
# -s = separator (splits on "---")Regex pattern:
# Regex separator
tac -r -s "^Chapter" file.txt
# -r = regex (treats separator as regex)Multiple files:
# Multiple files
tac file1.txt file2.txt
# Reverses each file separatelyAll together:
# Combined
tac file1.txt file2.txt > output.txt
# Reverses and combinesCheck installation:
# tac is part of coreutils
# Usually pre-installed
# Check tac
which tacThis guide covered tac usage, file reversal, and reverse file display for Arch Linux, CachyOS, and other distributions.
- cat Guide - Display files
- head Guide - View file beginnings
- tail Guide - View file endings
-
tac Documentation:
man tac
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.