Get the App
SLTechnology News&Howtos  ›  Servers  › 

Implementation example of Linux tac command

Shulou Source: shulou.com Published: 2022-06-02 04:45:01 10月05日 Update

1. Brief introduction to Command

The tac (reverse order of cat) command outputs the contents of the file in reverse order in behavior units, that is, the first line is displayed last and the last line is displayed first. The output is the opposite of the cat command.

two。 Command format

Tac [OPTION]... [FILE]...

If there is no file or the file is -, read standard input.

3. Option description

Mandatory parameters for long options are also mandatory for short options.

-b,-- before adds a separator before the line instead of the end of the line-r,-- regex parses the delimiter as a regular expression,-- separator=STRING specifies that the string replaces the newline as the line separator-- help displays help and exits-- version displays version information and exits

4. Common examples

Given the files file1 and file2 for testing, the contents are as follows:

File1 content:

one hundred and twenty three

four hundred and fifty six

seven hundred and eighty nine

File2 content:

Abc

Def

(1) reverse view the contents of the file.

Tac file1789456123

(2) look at the contents of the file in reverse, using the string b as the line separator.

Tac-s "b" file2cdefab

(3) Connect the files file1 and file2 to file3.

Tac file1 file2 > file3cat file3789456123defabc

reference

[1] tac (1) manual

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Tags: Content files commands flags lines messages characters strings help coercion output examples delimiters units parameters references that is commonly used mandatory newline characters Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MariaDB Microsoft Apple Xiaomi