Linux Common Commands--tac

Source: Internet
Author: User

1. Function: Reverse link and reverse print file

2. Usage: tac[option] file,TAC is used in the same way as cat, except that the file content is displayed in the opposite order.

Example:

Example 1: The order in which the content is printed, cat is printed sequentially, and the TAC is printed from the last line to the first row.

[email protected] ~]$ cat >test_cat.txt<<eof

> 5

> 4

> 3

> 2

> 1

> EOF

[email protected] ~]$ cat Test_cat.txt

5

4

3

2

1

[email protected] ~]$ TAC Test_cat.txt

1

2

3

4

5

Example 2:TAC input of keyboard data into a file is also reversed.

[email protected] ~]$ TAC >test_tac.txt<<eof

>5

>4

>3

>2

>1

>eof

[email protected] ~]$ cat Test_tac.txt

1

2

3

4

5

[email protected] ~]$ TAC Test_tac.txt

5

4

3

2

1

Example 3: When a file is stitched, the data will be written in the order of the files, but the contents of the file will be written to the new file in reverse.

[email protected] ~]$ cat >a.txt <<eof

> 1

> 2

> EOF

[email protected] ~]$ cat >b.txt<<eof

> 3

> 4

> EOF

[email protected] ~]$ tac a.txt b.txt >c.txt

[email protected] ~]$ cat C.txt

2

1

4

3


This article is from the "three countries Cold jokes" blog, please be sure to keep this source http://myhwj.blog.51cto.com/9763975/1785265

Linux Common Commands--tac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.