Skip to content

Linux tac Guide

Mattscreative edited this page Dec 5, 2025 · 3 revisions

Linux tac Guide

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.


Table of Contents

  1. tac Basics
  2. Reversing Files
  3. Separator Control
  4. Multiple Files
  5. Troubleshooting

tac Basics

Reverse File

Basic usage:

# Reverse file
tac file.txt

# Displays file in reverse order

From Input

Pipe input:

# Reverse from input
cat file.txt | tac

# Reverses piped input

Reversing Files

Line Reversal

Reverse lines:

# Reverse lines
tac file.txt

# Last line first, first line last

Multiple Files

Reverse multiple:

# Multiple files
tac file1.txt file2.txt

# Reverses each file

Separator Control

Custom Separator

Set separator:

# Custom separator
tac -s "---" file.txt

# -s = separator (splits on "---")

Regex Separator

Regex pattern:

# Regex separator
tac -r -s "^Chapter" file.txt

# -r = regex (treats separator as regex)

Multiple Files

Concatenate Reversed

Multiple files:

# Multiple files
tac file1.txt file2.txt

# Reverses each file separately

Combined Output

All together:

# Combined
tac file1.txt file2.txt > output.txt

# Reverses and combines

Troubleshooting

tac Not Found

Check installation:

# tac is part of coreutils
# Usually pre-installed

# Check tac
which tac

Summary

This guide covered tac usage, file reversal, and reverse file display for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally