Shell special symbol cut,sort_wc_uniq,tee_tr_split, Shell special symbol

Source: Internet
Author: User

Special symbols
    • * Any character
    • ? Any one character
    • Comment characters

      Indicates that the order does not take effect, and explains

    • \ de-Semantic characters
    • | Pipe breaks, several commands related to pipelines
      • Cut command: Intercept string

CAT/ETC/PASSWD |cut-d ":"-F

-D delimiter

-F Specify segment number

-c Specifies the number of characters, the use of the time can not use the-D,-F.

    • Sort: Sorting commands, by default in Asma order

-N is numerically sorted and the default letters and special symbols are considered to be 0

-R reverse sequence, with Asma in turn

-T separator character. -kn1/-kn1,n2

    • Wc-l: Statistics Row Count command
[[email protected] ~]# wc -l 1.txt 25 1.txt

WC-M: Number of statistics characters

[[email protected] ~]# wc -m 1.txt 487 1.txt

Wc-w: Statistical words, separated by blank characters

    • Uniq need to be adjacent to repeat the word to remove, so generally first sort after the removal of duplicate sort 2.txt |uniq-c

      -C Count of duplicate rows

Tee and > similar

Visual redirection

[[email protected] ~]# sort 1.txt > a.txt[[email protected] ~]# cat a.txt >.@ "111n1.txt* 2222333222444222555222aaaa2.txt3333334444444adm:x:3:4:adm:/var/adm:/sbin/nologinbin:x:1:1:bin:/bin:/sbin/ Nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinhalt:x:7:0:halt:/sbin:/sbin/haltlp:x:4:7:lp:/var/spool/lpd:/sbin /NOLOGINLS: Unable to access asffsfs.txt: No file or directory mail:x:8:12:mail:/var/spool/mail:/sbin/nologinoperator:x:11:0:operator:/ root:/sbin/nologiroot:x:0:0:root:/root:/bin/bashshutdown:x:6:0:shutdown:/sbin:/sbin/shutdownsync:x:5:0:sync:/ Sbin:/bin/sync[[email protected] ~]# sort 1.txt |tee a.txt>.@ 111n1.txt* 2222333222444222555222aaaa2.txt3333334444444adm:x:3:4:adm:/var/adm:/sbin/nologinbin:x:1:1:bin:/bin:/sbin/ Nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinhalt:x:7:0:halt:/sbin:/sbin/haltlp:x:4:7:lp:/var/spool/lpd:/sbin /NOLOGINLS: Unable to access asffsfs.txt: No file or directory mail:x:8:12:mail:/var/spool/mail:/sbin/nologinoperator:x:11:0:operator:/ Root:/sbin/nologiroot:x:0:0:root:/root:/bin/bashshutdown: x:6:0:shutdown:/sbin:/sbin/shutdownsync:x:5:0:sync:/sbin:/bin/sync[[email protected] ~]#  
    • |tee-a Visual Append redirect
    • TR Replacement Character
[[email protected] ~]# echo "aminglinux" |tr ‘a‘ ‘A‘Aminglinux
[[email protected] ~]# echo "aminglinux" |tr ‘[anx]‘ ‘[ANX]‘AmiNgliNuX
[[email protected] ~]# echo "aminglinux" |tr ‘[a-z]‘ ‘[A-Z]‘AMINGLINUX
Split cut
    • -b Specifies the split size: split-b 100M bigfile filename (does not write unit default display is bytes)
    • -l Specifies the number of split file lines: split-l bigfile filename
Shell Special Symbols
    • $ variable prefix,!$ combination, regular inside means end of line
    • ; Multiple commands written to one line, separated by semicolons
    • ~ User home directory, followed by regular expression to indicate match
    • & put the command behind the command and throw it backstage.
    • > >> 2> 2>> &>
    • [] One of the specified characters
    • || and &&, used between commands
      • || or the meaning of
      • &&
    • ||

      if | | The previous command prompt succeeded, | | The subsequent command will not execute, if the previous command execution is unsuccessful, the | | The following command.

    • &&

      If the previous command executes successfully, the subsequent command is executed, and if the previous command is wrong, the following command is not executed.

Shell special symbol cut,sort_wc_uniq,tee_tr_split, Shell special symbol

Related Article

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.