wildcard
- Wildcard: *
Matches zero or more characters. That is to say, "Anything is OK". Example:
- / etc/g* matches all files in / etc that begin with G.
- / tmp/my*1 starts with my in / tmp and matches all files ending with 1.
- Wildcard character: uuuuuuuuuuuu
Matches any single character. Example:
- Myfile? Matches with any file named myfile followed by a single character.
- / tmp/notes?txt will match / tmp/notes.txt and / tmp/notes_txt if they exist.
Annotation Symbol'"
Notes
- At the beginning of the shell file, as an include tag: #! /bin/bash.
- Used elsewhere as a comment, # will not be executed later.
Definition Character\
\ Symbol makes the character behind it just as the character itself and does not reflect the meaning of the character.
[root@localhost ~]# a=123;b=456 [root@localhost ~]# c=$a$b [root@localhost ~]# echo $c 123456 [root@localhost ~]# c=\$a\$b [root@localhost ~]# echo $c $a$b
Pipeline symbol and cut
Pipeline "|" is the output of the previous command as the input of the command after the pipeline. cut is a truncated string. cut partition, - d separator - f specifies which segment - c specifies which character
[root@localhost tmp]# cat 2.txt |cut -d ":" -f 1 root bin daemon adm [root@localhost tmp]# cat 2.txt |cut -d ":" -f 1,2 root:x bin:x daemon:x adm:x
sort sorting
Parameters:
- - n: Sort by the size of the values
- - r: Sort in reverse order;
- - T < Separating Character >: The field separating character used to specify the sort;
[root@localhost tmp]# cat 2.txt root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin [root@localhost tmp]# sort 2.txt adm:x:3:4:adm:/var/adm:/sbin/nologin bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin root:x:0:0:root:/root:/bin/bash
wc command
- Wc-l Statistical Row Number
- Wc-m Statistical Character Number
- Wc-w statistic word count (space as partition symbol)
[root@localhost tmp]# wc -l 2.txt 4 2.txt [root@localhost tmp]# wc -w 2.txt 4 2.txt [root@localhost tmp]# wc -m 2.txt 142 2.txt
The uniq command removes duplicates (sorting before duplicating)
[root@localhost tmp]# cat 3.txt 112233 223344 334455 556677 112233 223344 [root@localhost tmp]# sort -n 3.txt | uniq 112233 223344 334455 556677
tee command
Tee and > similar means redirect output, tee-a similar > redirect addition, such as sorting 3.txt, de-duplicating, and then output to 1.txt command as follows:
[root@localhost tmp]# sort 3.txt | uniq |tee 1.txt 112233 223344 334455 556677 [root@localhost tmp]# cat 1.txt 112233 223344 334455 556677
tee differs from > in that it displays redirected content on the screen, while > does not.
tr substitution character
tr aa bb = Replace character aa with character bb
[root@localhost tmp]# cat 1.txt 112233 223344 334455 556677 [root@localhost tmp]# tr '11' '99' < 1.txt 992233 223344 334455 556677
Chinese characters
The "| |" character is used between two commands to indicate that if the previous command fails to execute successfully, the subsequent command will be executed.
[root@localhost tmp]# cat 5.txt || cat 1.txt cat: 5.txt: No file or directory 112233 223344 334455 556677 [root@localhost tmp]# cat 1.txt || cat 5.txt 112233 223344 334455 556677
& Characters
& & Characters indicate that the previous command is executed successfully before the subsequent command is executed.
[root@localhost tmp]# mkdir lic && mv 1.txt lic [root@localhost tmp]# ls 2.txt 3.txt lic [root@localhost tmp]# tree lic/ lic/ └── 1.txt 0 directories, 1 file