Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Implementation example of Linux tac command

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report