Cut,sort,wc,uniq,tee,tr,split, and, and, or

Source: Internet
Author: User

Cut to segment a file

Cut-d: (Specifies the delimiter)-f (paragraph) 3,4,5/etc/passwd

CUT-C (intercept the first few characters) 1-10/etc/passwd


Sort used for sorting

SORT-T: (Specifies the delimiter)-K3 (paragraph)-N (Pure numeric sort)/etc/passwd

SORT-T: (Specify delimiter)-k3,5 (interval segment with, number, not used-)-N (Pure numeric sort)-R (reverse order)-U (de-duplication)/etc/passwd


Wc-l (number of lines in a document) 1.txt 2.txt

Wc-w (How many word words) 1.txt

Wc-m (number of characters, including one \ n) 1.txt


Uniq is mainly used to repeat.

Uniq-c (calculates how many repetitions) 2.txt if two duplicate rows are not next to each other, it is not going to repeat.

Sort 2.txt|uniq-c


Tee for redirection plus dual output

echo "Xuan" |tee 1.txt (redirect Xuan to 1.txt and then display Xuan on the screen)


TR is used to replace characters.

LS *.txt |tr ' A-Z ' A-z ' lowercase to uppercase

LS *.txt |tr ' abcde ' ABCDE ' one by one corresponds to the


Split is used to cut large files.

Split-b (according to size) 50m 1.txt

Split-l (according to line) 1.txt

The source file still exists after cutting

Split-l (according to the line) 1.txt +new_ (file name after cutting)


&& ls 1.txt && ls 2.txt #左边命令执行成功后 to execute the command on the right

If the previous command executes successfully, the subsequent command is executed, and if the previous command execution is unsuccessful, the subsequent command is no longer executed

|| or ls 1.txt | | LS 2.txt #左边命令执行不成功 to execute the command on the right

If the previous command execution is unsuccessful, the following command is executed

; The left command executes successfully, and the command behind it will execute

Cut,sort,wc,uniq,tee,tr,split, and, and, or

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.