006_Text processing tool

Posted liujun5319

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了006_Text processing tool相关的知识,希望对你有一定的参考价值。

1. wc : print newline, word, and byte counts for each file
    [[email protected] ~]# wc /etc/passwd
         44   88 2301 /etc/passwd
    -l: lines
    -w: words
    -c: characters
2. cut : remove sections from each line of files
    2.1 Commondly used options
        -d DELIMITER: specify the delimiter
        -f FILEDS:
            #: filed #
            #,#[,#]:Discrete(离散的) multiple filed,such as 1,3,6
            #-#:Consecutive(连续的) fields, such as 1-6
            a mixture use of -f :1-3,7
        --output-delimiter=STRING : specify the delimiter when print contents.
    2.2 example
        [[email protected] ~]# cut -d‘ ‘ -f 1 /etc/fstab
            The space key as the delimiter,print filed 1        
        [[email protected] ~]# cut -d: -f1 /etc/passwd
        [[email protected] ~]# cut -d: -f1-7 /etc/passwd
        [[email protected] ~]# cut -d: -f1-4 --output-delimiter=‘--‘ /etc/passwd   //specify output delimiter
3. sort : sort lines of text files
    3.1 Commondly used options
        -f: ignore case
        -r: sort in reverse
        -t DELIMITER: delimiter
        -k #:Sort by specified filed, and sort by ASCII by default
        -n: sort by numerical value
        -u: uniq,omit repeated lines after sorting
    3.2 example
        [[email protected] ~]# sort /etc/passwd
        [[email protected] ~]# sort -t: -k3 /etc/passwd
4. uniq : report or omit repeated lines
    4.1 repeat : continues and equal is repeat
    4.2 uniq can only omit repeated lines and cannot sort. sort -u omit repeated lines and sort at the same time.
    4.3 Commondly used options
        -c: print the number of repeated lines
        -d: Only print repeated lines
        -u: Only print lines that do not repeated.

5. exerciese :Seperated by colon,and take lines 6 to 10 of the /etc/passwd file and sort the information by numerical value of the third field , then only show the first field.







































以上是关于006_Text processing tool的主要内容,如果未能解决你的问题,请参考以下文章

Java千百问_01基本概念(006)_线程和进程有什么区别

006-Process-Pool-Queue

HTML_006_VSCode工具基本使用

006.头文件 | 基础知识

python基础篇_006_面向对象

006_函数