shell special symbols
cut command (cut column)
-d specifies the delimiter -f specifies the cutoff column
[root@glinux-01 ~]# cat /etc/passwd|head -10|cut -d ":" -f 1,2
root:x
bin:x
daemon:x
adm:x
lp:x
sync:x
shutdown:x
halt:x
mail:x
operator:x
-c specifies the number of characters
[root@glinux-01 ~]# cat /etc/passwd|head -3|cut -c 2
o
i
a
sort_wc_uniq command
- sort sort (no option to sort numerically, alphabetically)
[root@glinux-01 ~]# cat 1.txt|sort
1
2
3
a
b
c
-n sorts numerically, letters are smaller than numbers
[root@glinux-01 ~]# cat 1.txt|sort -n
a
b
c
1
2
-r reverse sort
[root@glinux-01 ~]# cat 1.txt|sort -nr
3
2
1
c
b
a
- wc statistics command (-l count lines -m count characters -w count words)
wc 1.txt 2 lines, 2 words, 8 characters (newlines are also counted)
[root@g_linux01 ~]# cat -A 1.txt
123$
abc$
[root@g_linux01 ~]# wc 1.txt
2 2 8 1.txt
- uniq deduplication command (can only deduplicate in order, so it is often used with sort)
[root@g_linux01 ~]# cat 1.txt
123
abc
123
1
1
[root@g_linux01 ~]# uniq 1.txt
123 //123没去重
abc
123
1 //1去重了
Sort first, then deduplicate -c repeat count
[root@g_linux01 ~]# sort -n 1.txt|uniq -c
1 abc
2 1
2 123
tee_tr_split command
- tee redirect to file and print to screen (-a appends to file > redirect does not print)
[root@g_linux01 ~]# sort -n 1.txt|uniq -c|tee a.txt
1 abc
2 1
2 123
[root@g_linux01 ~]# cat a.txt
1 abc
2 1
2 123
[root@g_linux01 ~]# sort -n 1.txt|uniq -c|tee -a a.txt
1 abc
2 1
2 123
[root@g_linux01 ~]# cat a.txt
1 abc
2 1
2 123
1 abc
2 1
2 123
- tr replace command
[root@g_linux01 ~]# echo 'helloworld'|tr 'h' 'H'
Helloworld
[root@g_linux01 ~]# echo 'helloworld'|tr '[a-z]' '[A-Z]'
HELLOWORLD
- split cutting command (-b specifies the cutting size -l specifies the number of cutting lines)
split -b 100M [filename] Cut the file by 100M each
Specify the file name after cutting
-l 1000 specifies that the file is cut by 1000 lines each
under shell special symbols
> redirect >> append redirect 2 > error redirect 2 >> error append redirect &> correct error redirect
|| Logic
Command 1 || Command 2 Command 1 is executed successfully, then command 2 is not executed
Example: [ -d test ] || mkdir test interprets whether test exists and whether it is a directory, if not, create the test directory
&&Logical AND
Command 1 && Command 2 Command 1 is successful, then execute command 2