Text viewing and processing tools:
WC [OPTION] FILE ...
-C: Number of bytes
-L: Number of rows
-W: number of words
W.H.O. | Wc-l: View current number of users
Cut [OPTION] FILE ...
-D CHAR: Specify field delimiter
If this option is not added, the default is separated by a space
-F #|#-#|#,#: Specify the fields to display
Cut-d:-F 1/etc/password
Cut the/etc/password file with a colon and display the first field
That is, lists the first field in the current/etc/password, the user name
Cut-d:-F 1,3/etc/password
Show first and third fields of colon split
Cut-d:-F 1-3/etc/password
Show first to third field of colon split
Cut-f 1-3/etc/password
Default first to third field separated by a space separator
Sort [OPTION ...] FILE ...
-N: Sort by numeric size
-R: Reverse order
-F: Ignore character case
-T CHAR: Specify field delimiter
-K #: Specifies the field to use for sorting
-U: Duplicate rows are retained only once
Cut-d:-F 3/etc/password | Sort-n
Sort by the size of the value in the third column of the/etc/password file
Sort-n/etc/password
Sort the letters at the beginning of the line
Sort-t:-K 3-n/etc/password
Sort the third field after a colon split
Sort-n-u/tmp/test
Duplicate rows are displayed only once
Uniq [OPTION ...] FILE ...
-C: Shows the number of occurrences of each line;
-D: Show only duplicate rows;
-U: Displays only rows that have not been duplicated;
Uniq-c/tmp/test
Uniq-d/tmp/test
Uniq-u/tmp/test
Exercise: Remove the IP address from the ifconfig eth0 result;
# ifconfig Eth0 | head-2 | Tail-1 | Cut-d:-F 2 | Cut-d ""-F 1
Bash text viewing and processing tools