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

时间:2021-01-26
本文章向大家介绍Linux Sysadmin Basics 4.1 -- Filtering Output and Finding Things (&&, cut, sort, uniq, wc, grep),主要包括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

原文地址:https://www.cnblogs.com/goldenretriever/p/14332748.html