cut、sort、wc、uniq、tee、tr、split
Others
2022-04-27 12:45:09
views: 0
8.10 shell special symbol _cut command
- *any arbitrary character
- ? any character
- #comment characters
- \ escape character
- |pipe
- Several commands related to pipes
- cut to split, -d separator -f specifies the segment number, -c specifies the number of characters
# cat /etc/passwd |head -2 |cut -d ":" -f 1
to: split, display the first segment
# cat /etc/passwd |head -2 |cut -d ":" -f 1,2
with: split, display the first and second segments with: split, display the first, second
# cat /etc/passwd |head -2 |cut -d ":" -f 1-3
, and third segments
# cat /etc/passwd |head -2 |cut -c 4
- sort sort (sort by ASCII code by default), -n sort by number (letters and special symbols will be considered as 0) -r sort in reverse order -t separator (specify which paragraph to sort, rarely used) -kn1/-kn1 ,n2 (rarely used)
# sort /etc/passwd
- wc-l count lines -m count characters -w count words (with blank characters as separators)
# wc -l 1.txt
# wc -m 1.txt
# wc -w 1.txt
- uniq deduplication, -c counts the number of duplicate lines
# sort -n 2.txt | uniq -c
- tee is similar to >, it is also displayed on the screen while redirecting, -a appends and displays the
# sort -n 2.txt |uniq -c |tee a.txt
# sort -n 2.txt |uniq -c |tee -a a.txt
# >2.txt
command to clear 2.txt
- tr replaces characters, tr'a' 'b', case replaces tr '[az]' '[AZ]'
# echo "aminglinux" |tr '[al]' '[AL]'
- split cuts -b size (default unit byte), -l number of lines
# split -b 100M bigfile
# split -l 1000 bigfile
8.11 sort_wc_uniq command
8.12 tee_tr_split command
8.13 Under special shell symbols
- $variable prefix, !$ combination, which means the end of the line
- ; Multiple commands are written on one line, separated by semicolons
- ~User home directory, followed by a regular expression that represents a match
- & put after the command, it will drop the command to the background
>,>>,2>,2>>,&>
&> The correct and incorrect output contents are all entered into one file
- [] specifies one of the characters, [0-9],[a-zA-Z],[abc]
- || and &&, used between commands
- ||The previous command is successful but the latter command is not executed, the former command is unsuccessful and the latter command is executed
- && If the previous command is executed successfully, the latter command will be executed. If the previous command is unsuccessful, the latter command will not be executed.
expand
- Source exec differencehttp ://alsww.blog.51cto.com/2001924/1113112
- Linux special symbols Daquan http://ask.apelearn.com/question/7720
- sort is not sorted by ASCII http://blog.csdn.net/zenghui08/article/details/7938975
Origin http://43.154.161.224:23101/article/api/json?id=325621322&siteId=291194637
Linux study notes (6) - Operation Command review (wc, sort, uniq, cut, tee, xxd, history, more, less, tail, tail -f, echo)
Commonly used text processing shell command: find, grep, xargs, sort, uniq, tr, cut, paste, wc, sed, awk