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