Linux character processing

Source: Internet
Author: User
Pipeline |
grep search Text
Grep-i-c-n-V ' requires matching characters ' file name
Cat Test.txt | Grep-iv ' Zhangsan '
Sort by using sort
Sort-n Numeric sort-T Specify delimiter-K Specify the number of columns-R reverse Sort
The default is sorted by the first character in each line
Cat Test.txt | Sort-r-T ":"-K 2-n
Use Uniq to remove duplicate content
Uniq-c computes duplicate row-I ignores case
Uniq usually work with sort, and then go back to the first
Note Uniq The criterion of repetition is to encounter successive lines that are exactly consistent, and if multiple lines in a file are identical, but they are discontinuous, uniq will not be processed.
Use cut to intercept text, process it by line, and capture the desired part from it.
Cut-f Specify column-d ' delimiter '
cat/etc/passwd | Cut-f 1,6-7-d ': ' #截取出每行的第1和第6列第7列
Cut-c the delimiter for the specified column
cat/etc/passwd | head-3 | Cut-c 1-5,7-10 #截取每行的第1-5 characters, 第7-10 characters
Using TR to do text conversion
Cat passwd | TR ' [A-z] ' [A-z] ' #把全部的小写字母都转换为大写
Cat passwd | Tr-d ': ' #删除冒号
Use paste to do text merge
Split large files using split to split by row or by size

Linux character processing

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.