Linux Sysadmin Basics 4.1 -- Filtering Output and Finding Things (&&, cut, sort, uniq, wc, grep)

  • cut OPTION… [FILE]…

    remove sections from each line of files

    -d, --delimiter=DELIM
                  use DELIM instead of TAB for field delimiter

    -f, --fields=LIST
                  select only these fields; also print any line that contains no delimiter character, unless the -s option is specified

  • sort [OPTION]... [FILE]...

    or sort [OPTION]... --files0-from=F

    sort lines of text files

    -b, --ignore-leading-blanks
                  ignore leading blanks

    -f, --ignore-case
                  fold lower case to upper case characters

  • uniq [OPTION]... [INPUT [OUTPUT]]

    report or omit repeated lines

  • wc [OPTION]... [FILE]...

    or wc [OPTION]... --files0-from=F

    print newline, word, and byte counts for each file

  • grep [OPTIONS] PATTERN [FILE...]

    or grep [OPTIONS] -e PATTERN ... [FILE...]

    or grep [OPTIONS] -f FILE ... [FILE...]

    print lines matching a pattern


# file.txt

dave:we

user:love

someone:linux

someone:linux

prog1 && prog2
cat file.txt | cut -d: -f2
cat file.txt | sort -bf
cat file.txt | uniq
wc file.txt
cat file.txt | grep user
posted @ 2021-01-26 22:22  Blind  阅读(71)  评论(0编辑  收藏  举报