Sort
Function: Sort Text to display
Common options:
-U Remove Duplicate rows
-R Descending (default ascending)
-N Sort by numeric value
-T Specify delimiter
-k n Sorted by nth column
Instance:
[[email protected] ~]# cat hi a:2b:3b:1b:1c:4d :5[[email protected] ~]# sort -u hi a:2b:1b:3c:4d:5[[email protected] ~]# sort -r hi d:5c:4b:3b:1b:1a:2[[email protected] ~]# sort -n Hi a:2b:1b:1b:3c:4d:5[[email protected] ~]# sort -u -t : -k 2 -n hib:1a:2b:3c:4d:5[[email protected] ~]# sort -u -t : -k 2 hib:1a:2b:3c:4d:5[[email protected] ~]#
Tr
function: Replace, delete character
Format: Tr-c-d-s ["String1_to_translate_from"] ["string2_to_translate_to"] < Input-file
Common options:
-C replaces all characters that are not part of the first character set
-D Delete all characters belonging to the first character set
-S character selector replace with Word II
Comments:
When specifying the contents of string 1 or String 2, only single character or string range or list can be used.
A string that consists of characters in A-Z (A-Z).
[A-z] A string consisting of characters within a-Z.
[0-9] number string.
\octal a three-bit octal number that corresponds to a valid ASCII character.
[O*n] indicates that the character O repeats the specified number of times N. therefore [o*2] matches the OO string.
Instance:
[[email protected] ~]# cat Hiabbcd[[email protected] ~]# tr-s "a B" "a" < Hiaaacd[[email protected] ~]# tr [A-z] [a-z] < Hiabbcd[[email protected] ~]# tr-d "b d" < Hiac[[email protected] ~]# tr-s "\ n" < Hiabbcd[[email protected] ~ ]#
cut
Role: Intercept string
Common options:
-b : Split in bytes. These byte locations will ignore multibyte character boundaries unless the-n flag is also specified.
-c: Split in characters.
-d: A custom delimiter, which defaults to a tab.
-f : Used with-D to specify which area to display.
-n: Cancels splitting multibyte characters. Used only with the-B flag. If the last byte of the character falls within the range of <br/> indicated by the List parameter of the-B flag, the character will be written out; otherwise, the character will be excluded.
Instance:
[[email protected] ~]# cat hiroot:x:0:0:root:/root:/ bin/bash[[email protected] ~]# cat hi | cut -b 5:[[email protected] ~]# cat hi | cut -b 3-5,7ot::[[email protected] ~]# cat hi | cut -c 5:[[email protected] ~]# cat hi | cut -c 4-6,8t:x0[[email protected] ~]# cat hi2 Monday Tuesday Wednesday Thursday [[email protected] ~]# cat hi2 | cut -b 3 [[email PROTECTED]&NBSP;~]#&NBSP;CAT&NBSP;HI2&NBSP;|&NBSP;CUT&NBSP;-C&NBSP;3 1234-C will be in characters, the output is normal, and-B will only be silly in bytes (8-bit bits) to calculate , the output is garbled. [[email protected] ~]# cat hiroot:x:0:0:root:/root:/bin/bash[[email protected] ~ ]# cat hi | cut -d : -f2-4,6x:0:0:/root[[email protected] ~]#
Paste
Role: Merging multiple file contents
Common options:
-D Specify delimiter
-S merges text into a single line
Instance:
[email protected] ~]# cat one tworoot:x:0:0:root:/root:/bin/bash1:2:34:5:67:8:9[[email protected] ~]# paste one tworoot : X:0:0:root 1:2:3:/root:/bin/bash 4:5:6 7:8:9[[email protected] ~]# paste-d "+" one Tworoot:x:0:0:root+1:2:3:/ro Ot:/bin/bash+4:5:6+7:8:9[[email protected] ~]# paste-s one tworoot:x:0:0:root:/root:/bin/bash 1:2:3 4:5:6 7: 8:9[[email protected] ~]#
Uniq
Action: Removes duplicate rows from a sorted file
Common options:
-C Displays the number of occurrences of the row next to each column
-D displays only columns with duplicate rows
-U displays only non-repeating rows
Instance:
[[email protected] ~]# cat Hiaabcdde[[email protected] ~]# uniq hiabcde[[email protected] ~]# uniq-c hi 2 a 1 b 1 C 2 D 1 e[[email protected] ~]# uniq-d Hiad
find
Role: Find a file or directory [do the appropriate processing]
format: Find [options] path [action]
Common options:
-name Search by file name (wildcard characters supported)
-size Search by size
-prem Search by permissions
-user Find
-group In user groups with user host
-mtime -n +n by file change time lookup -n means n days or less, +n refers to n days ago
-ctime Search by file creation time
-type Find by file type
instance:
Find the name of the user Jacken in the/directory contains the Jacken file and the size exceeds 15M and has been modified within one day, and then copied to/TMP [[email protected] ~]# Find/-name *jacken*-user Jacken- Type F-size +15m-mtime-1-exec cp {}/tmp/\; [[email protected] ~]# ll/tmp/total 20480-rw-r--r--1 root root 20971520 Apr 1 10:18 jacken_file[[email protected] ~]#
Watch
Function: Real-time monitoring of command run results
Common options:
-D Highlighting changes
-N Period (seconds)
Instance:
[[email protected] ~]# watch-d-N. 5 ls every 0.5 seconds ls a bit
Ctrl + Z can run commands that are executing in the background
for those commands that are placed in the background, only in the current shell can view the
Jobs
Role: See how many commands are currently running in the background
FG
Role: Move the process to the foreground run
BG
Role: Move the process to the background run
instance:
[[email protected] ~]# jobs[[email protected] ~]# dd if=/dev/zero of=/ dev/null bs=1g count=100^z[1]+ stopped dd if=/dev/zero of=/dev/null bs=1G count=100[[email protected] ~]# cat /dev/zero >> /dev/null ^z[2]+ Stopped cat /dev/zero >> /dev/null[[email protected] ~]# jobs[1]- Stopped dd if=/dev/zero of=/dev/null bs=1G count=100[2]+ Stopped cat /dev/ zero >> /dev/null[[email protected] ~]# bg 1[1]- dd if=/dev/zero of=/dev/null bs=1g count=100 &[[email protected] ~]# jobs[1]- Running dd if=/dev/zero of=/dev/null bs=1g count=100 &[2]+ stopped cat /dev/zero >> /dev/ Null[[email protected] ~]# bg 2[2]+ cat /dev/zero >> /dev/null &[[email protected] ~]# jobs[1]- Running dd if=/dev/zero of=/dev/null bs=1G count=100 &[2]+ Running cat /dev/zero >> /dev/null &[[email protected] ~]# fg 1dd if=/dev/zero of=/dev/null bs=1g count=100^z[1]+ Stopped dd if=/dev/zero of=/dev/null bs=1G count=100[[email protected] ~]# jobs[1]+ stopped dd if=/dev/zero of=/dev/null bs=1G count=100[2]- running cat /dev/zero >> /dev/null &[[email protected] ~]# bg 1[1]+ dd if=/dev/zero of=/dev/null bs=1G count=100 &[[email protected] ~]# jobs[1]- runniNg dd if=/dev/zero of=/dev/null bs=1G count=100 &[2]+ Running cat /dev/zero >> /dev/null &[[email protected] ~]#
This article from "Step by step into the Linux World" blog, declined reprint!
Common basic commands for Linux 12