Shell special Characters
- * Any of the characters
- ? Any one character
- #注释字符
- \ de-Semantic characters
- | pipe character
- $ variable prefix,!$ combination, regular inside means end of line
- Multiple commands are written to one line, separated by semicolons.
- ~ User home directory, regular expression indicates match
- & put the command behind the command and throw it backstage.
- \>,>>,2>,2>>,&> (correct and error redirect)
- [] One of the specified characters, [0-9],[A-ZA-Z],[ABC]
- || When the preceding command succeeds without executing the following, the preceding is unsuccessful before executing the
- && when the previous command does not succeed do not execute behind, the previous success is executed behind OH
Cut command
- Intercept string
- -d Specifies the delimiter,-f specifies to intercept the specified field number, and-C to specify the first few characters
[[email protected] ~]# cat /etc/passwd |head -2root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologin[[email protected] ~]# cat /etc/passwd |head -2 |cut -d ":" -f 1rootbin[[email protected] ~]# cat /etc/passwd |head -2 |cut -d ":" -f 1,2root:xbin:x[[email protected] ~]# cat /etc/passwd |head -2 |cut -d ":" -f 1-3root:x:0bin:x:1[[email protected] ~]# cat /etc/passwd |head -2 |cut -c 4t:
Sort command
- ASCII sorting, alphabetical order
[[email protected] ~]# sort /etc/passwdadm:x:3:4:adm:/var/adm:/sbin/nologinaming:x:1000:1000::/home/aming:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologinchrony:x:997:995::/var/lib/chrony:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologin
- -N is numerically sorted, letters and special symbols default to zero
[[email protected] ~]# sort-n 1.txt[]adm: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/nologinmail:x:8:12:mail:/var/spool/mail:/sbin/nologinoperator:x:11:0:o perator:/root:/sbin/nologinroot:x:0:0:root:/root:/bin/bash*sdshdjhjshutdown:x:6:0:shutdown:/sbin:/sbin/ SHUTDOWNSYNC:X:5:0:SYNC:/SBIN:/BIN/SYNC22AAA2222222AAAAAA111344442222211114234234252SDADHKAJHKJ
- -R Reverse Order
[[email protected] ~]# sort -nr 1.txt4234234252sdadhkajhkj222221111111344442222222aaaaaa22aaasync:x:5:0:sync:/sbin:/bin/syncshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown*sdshdjhjroot:x:0:0:root:/root:/bin/bashoperator:x:11:0:operator:/root:/sbin/nologinmail:x:8:12:mail:/var/spool/mail:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd:/sbin/nologinhalt:x:7:0:halt:/sbin:/sbin/haltdaemon:x:2:2:daemon:/sbin:/sbin/nologinbin:x:1:1:bin:/bin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologin}
- -T delimiter,-kn1/-kn1,n2
WC command
Uniq command
- Go to Heavy,-C statistics line number of rows to heavy
[[email protected] ~]# sort 2.txt 111231232abcabc 111,222[[email protected] ~]# sort 2.txt |uniq11232abcabc 111,222[[email protected] ~]# sort 2.txt |uniq -c 1 2 1 2 123 1 2 1 abc 1 abc 111,222
Tee command
TR Replacement Character
[[email protected] ~]# echo "aminglinux" |tr ‘[al]‘ ‘[AL]‘AmingLinux[[email protected] ~]# echo "aminglinux" |tr ‘[a-z]‘ ‘[A-Z]‘AMINGLINUX
Split command
Test
Shell special characters, Cut,sort,wc,uniq,tee,tr,split command