---
title: "tac command"
description: "The tac command is much like its brother, the cat command. It also concatenates and prints a file to the screen. However, the tac command does this in reverse. This can be especially useful if you..."
url: https://www.inmotionhosting.com/support/server/linux/tac-command/
date: 2014-06-05
modified: 2022-03-31
author: "Scott Mitchell"
categories: ["Linux"]
type: post
lang: en
---

# tac command

The *tac* command is much like its brother, the [*cat* command](https://www.inmotionhosting.com/support/server/linux/using-the-linux-cat-command/). It also concatenates and prints a file to the screen. However, the *tac* command does this in reverse. This can be especially useful if you are looking for information that should be at the end of a long log file. For instance, if you needed to pull information on an email that was sent today and the log file rotates monthly, it would be more efficient to use the *tac* command as opposed to the *cat* command. The information will be printed to the screen in reverse order, starting at the last line.

**Command: **tac
**Synopsis: **tac ... ...

**Options: **
Below are the different options that are available to customize the *cat* command.

| Option | Long Name | Description |
| --- | --- | --- |
| -b | --before | Attach the separator before instead of after. |
| -r | --regex | Interpret the separator as a regular expression. |
| -s | --separator=STRING | Use STRING parameter as the separator instead of newline. |

## Examples

**Base command** This example uses the base *tac* command on a file named test.txt. This is the same file used in the *cat* article, so you can see that it is printed to the screen in reverse.

$# tac test.txt adipiscing sapien. Cras vel aliquet massa. Mauris quis auctor eros. Ut gravida tellus at nisi facilisis, adipiscing cursus nisi luctus. Morbi eu dictum felis. Morbi vel ipsum nunc. Nunc ac sapien viverra, dignissim arcu vitae, gravida magna. Phasellus a imperdiet egestas sit amet eget ante. Nulla at fermentum turpis. In convallis leo nec lectus accumsan, id vehicula dui tincidunt. Proin eget pellentesque lectus. Duis id mauris vel massa Lorem ipsum dolor sit amet, consectetur adipiscing elit.
