Cat: Connect and display, such as:
[Email protected] ~]# cat/tmp/sort.test 111324567324890890567ABC
Plus the option-n Displays the line number:
[Email protected] ~]# cat-n/tmp/sort.test 1111 2324 3567 4324 5890 6890 7567 8abc
The Plus-e option displays the line-ending character $: (the end of the Linux row is $)
[Email protected] ~]# cat-e/tmp/sort.test111$324$567$324$890$890$567$abc$
The TAC is synonymous with cat, but is displayed with its inverse:
[Email protected] ~]# tac/tmp/sort.test abc567890890324567324111
The more and less commands are used for split-screen viewing of files, unlike the more command to check text to the tail after it cannot be seen, less can, so generally use less, you can open the file test with Less/etc/rc.d/rc.sysinit. Operation Method:
Space: Turn back one screen;
B Key: Turn one screen ahead;
Enter: Display a row in the future;
K Key: Forward one line;
Head command: View the first few lines of the file, default to the first 10 lines: [[email protected] ~]# head/tmp/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/ sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/ lpd:/sbin/nologinsync:x:5:0:sync:/sbin:/bin/syncshutdown:x:6:0:shutdown:/sbin:/sbin/shutdownhalt:x:7:0:halt:/ Sbin:/sbin/haltmail:x:8:12:mail:/var/spool/mail:/sbin/nologinnews:x:9:13:news:/etc/news:
With parameter-n displays the first n rows:
[Email protected] ~]# head-5/tmp/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x : 2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin[[ Email protected] ~]#
Tail and head use the same method, just display a few lines of the tail.
But tail has a useful option:-F, open the file without exiting, implement the trailing input of the monitoring file, or add new content.
(You can use Xshell to open two terminals to self-test.) )
Cut
Cut general combination options are used:
Cut-d:-F 3/ETC/PASSWD
Description:-D: means ":" As a delimiter,-f 3 means to display the third column with ":" as the delimiter;
Sort: Sorts the lines in the contents of the file, with the usual options of-r-t-K;
-R is the reverse sort, the-t specifies the delimiter,-K is sorted with a position of key:
Sort-t:-K 3/tmp/passwd, which means that all rows are sorted by the third column ":" As the delimiter;
Uniq: Displays or ignores duplicate rows, noting that only adjacent and identical rows are considered duplicates, such as the contents of the Sort.test file:
[Email protected] ~]# cat/tmp/sort.test 111324567324890890567ABC
Using the Uniq command, you can see that the original line "890" is ignored and shown:
[Email protected] ~]# UNIQ/TMP/SORT.TEST111324567324890567ABC
-D: Show only duplicate rows
[Email protected] ~]# uniq-d/tmp/sort.test890
-D: Show all duplicate rows
[Email protected] ~]# uniq-d/tmp/sort.test890890
-C Displays the number of times the row repeats [[email protected] ~]# uniq-c/tmp/sort.test 1 111 1 324 1 567 1 324 2 890 1 567 1 ABC
WC command: Displays the number of lines, words, and digits of the file
[Email protected] ~]# Wc/tmp/sort.test 8 8 32/tmp/sort.test
Option:-L displays only the number of rows,-C displays only the number of digits, and-W displays only the number of words;
TR command: convert or delete characters;
such as TR CD CD:
[Email protected] ~]# TR CD CDABCDABCD
Under this input model, you can press (CTRL + C) to terminate the command.
TR A-Z:
[Email protected] ~]# TR A-Z A-ZABCDABCD
Tr-d A: (-d delete specified characters)
[Email protected] ~]# tr-d AABCDBCD
Use of the Linux CAT,TAC,MORE,LESS,HEAD,TAIL,CUT,SORT,UNIQ,WC,TR command