Shell Special Symbols

Source: Internet
Author: User

1. Special symbols

For more information, see

2, about the pipe character

(1), cut split
-D delimiter-F Specify segment number-C to specify the first character
For example, see,

Example, | Output, cut splits out the desired results later. In general,-C and-D,-F are not used at the same time.

(2), sort order
-N Sort by number-R inverse-T delimiter-kn1/-kn1,n2
For example, see,

It can be noted that the contents of the red box are arranged alphabetically, which is the result of the sort effect. After the sort is not followed by any options, the first character is backward, then the ASCII values are compared, and finally they are output in ascending order.

On the ASCII code, Baidu Encyclopedia interpretation is as follows:

And then down, see,

Enter after the carriage return,

Randomly enter the contents of the red box and exit after saving. Using sort to view file 1.txt, see,

You can see the order of the first special symbol, then the number, and then the letter, including the * number. This is the order in which ASCII codes are arranged.
The-n option is sorted numerically, preceded by a special symbol and letter, which defaults to 0. See

The-r option is the reverse order of the meaning, see,

-T followed by delimiters,-kn1/-kn1,n2, these are used relatively little, understand can.

(3), WC
-l statistic number of rows-m statistic characters-W statistics
As an example, see,

Enter the 2.txt file, edit the contents of the red box,

Exit after saving. Then count the number of characters in 2.txt, see,

As you can see, the number of characters in 2.txt is 8, why is it 8? Cat-a said before, it can view all the contents of the 2.txt file, including hidden. Then, you see the $ at the end of each line, which represents a newline character. So, the result of Wc-m 2.txt is 8.
Then the-W operation, see,

2. TXT has two lines of content, so the result is 2. Again into the 2.txt edit file content, see,

After you have finished adding content, save and exit. Look at the statistics again, see,

-W is delimited with a white-space character, so the result is displayed as 3.

(4), Uniq to repeat,-C count rows
Input command VI 2.txt, enter, see,

Add the contents of the red box, save and exit. Then proceed down,

found that the Uniq command on the content of 2.txt has no effect, re-enter the file 2.txt, the following editing content,

Swap the last 1 and 2 positions, and then save the exit. Then use the command Uniq 2.txt to view, see,

At this time, you will see to repeat. This is conditional to repeat, must be two identical characters in front and back position in order to repeat.
In general, uniq and sort are used together, see,

Sort first, then repeat. This way, after you use the command, you don't see the duplicate values. You can also use the-C option to count the number of repetitions, and the number in front of each row is the number of repetitions.

(5), Tee
Similar to >, redirects are also displayed on the screen, |TEE-A has an additional function
For example, see,

It can be seen that one of the functions of |tee is redirection, and one of the functions is to print the contents of the file to the screen.
The-a option has the added effect, see,

One more time, then look at the file, see,

(6), tr command
TR replacement character, tr ' a ' B ', case replacement TR ' [A-z] ' [A-z] '
Specific operation, see,

(7), Split command
Split Cut,-B size (default unit byte),-L line number
First to create a large file, enter the command find/etc/-type f-name "conf", enter, see,

This command results in too many content, not one by one, followed by the following actions,

The following 4.0 KB files are also many, not all of them. Then use the command Du-sh, enter, see,

The content is also very much, not one by one. 1000 units are B. Because the front cutting unit is 1000, then cut to 100, see,

After cutting into 100, the file is more, the picture content is not complete, you can notice that these small files are named in alphabetical order. Too many files, delete them all, and then proceed down,

Shell Special Symbols

Related Article

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.