cut、sort、wc、uniq、tee、tr、split

8.10 shell special symbol _cut command

  1. *any arbitrary character
  2. ? any character
  3. #comment characters
  4. \ escape character
  5. |pipe
  6. Several commands related to pipes
    1. cut to split, -d separator -f specifies the segment number, -c specifies the number of characters
      # cat /etc/passwd |head -2 |cut -d ":" -f 1to: split, display the first segment
      # cat /etc/passwd |head -2 |cut -d ":" -f 1,2with: 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
    2. 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
    3. 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
    4. uniq deduplication, -c counts the number of duplicate lines
      # sort -n 2.txt | uniq -c
    5. 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.txtcommand to clear 2.txt
    6. tr replaces characters, tr'a' 'b', case replaces tr '[az]' '[AZ]'
      # echo "aminglinux" |tr '[al]' '[AL]'
    7. 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

  1. $variable prefix, !$ combination, which means the end of the line
  2. ; Multiple commands are written on one line, separated by semicolons
  3. ~User home directory, followed by a regular expression that represents a match
  4. & put after the command, it will drop the command to the background
  5. >,>>,2>,2>>,&>&> The correct and incorrect output contents are all entered into one file
  6. [] specifies one of the characters, [0-9],[a-zA-Z],[abc]
  7. || and &&, used between commands
    1. ||The previous command is successful but the latter command is not executed, the former command is unsuccessful and the latter command is executed
    2. && 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

  1. Source exec differencehttp ://alsww.blog.51cto.com/2001924/1113112
  2. Linux special symbols Daquan http://ask.apelearn.com/question/7720
  3. sort is not sorted by ASCII http://blog.csdn.net/zenghui08/article/details/7938975

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325621322&siteId=291194637