Text editing:
To view text content:
Cat: Connect and display the file
-N: Numbering each line of the file when displayed
TAC: Similar to cat, but its function is to display each line of file in reverse order
[Email protected]:~/linlin/test$ cat Sort.txt
5431
1234
1234
[Email protected]:~/linlin/test$ TAC Sort.txt
1234
1234
5431
NL: Add line number when displayed
-B: Specify how line numbers are displayed
-B A: line numbers are listed regardless of whether they are blank lines
-B T: Empty lines do not list line numbers if there are blank lines
-N: Specify line number position
-N LN: line number is displayed at the left of the screen
-N RN: line number is displayed to the right of the field and does not add 0
-N RZ: line number appears to the right of the field, plus 0
[Email protected]:/home/linlin/linlin/text# nl sort.test
1 12312:213:12312:2341
2 1232:231:2131:1231
3 12:23124:2131:124
4 12314:1234:121:12341
5 12441:3543:241:4
Page view:
MORE: A page-by-page flip
If the file is too large to be fully displayed on the screen, the current display percentage is displayed on the last line
Operation:
Enter key: Turn down one line
SPACEBAR: Turn down one page
/string: Search down string
: F: Show file name and currently displayed line number
Q: Exit
Less: In contrast to more, much more flexible, more unable to page forward, but less can be both forward and backward page
Operation:
Space bar: Page Down
Pgdown: Page Down
PgUp: Page Up
? Keyword: Forward search
/key word: Search backwards
N Next
N previous One
Use Q to Exit View status
Head: View the first n rows of the file, n the default value is 10
Tail: View the file after n rows
-N: Sets the number of rows, can also omit N, write directly-number
For example Head-n 7 = head-7
One use of tail:
Tail-f: View the end of the file, and do not exit the view status if the file being viewed
There is a new content that will be displayed continuously. Common use and monitoring
OD: Reading non-plain text files
Usage: od-t type file
Type:
A: Using the default character output
C: Use ASCII character output
D: output data using decimal
O: Octal
X: Hexadecimal
Cut: Cut file and Show
-D: Specifies the delimiter when cut, default to a space
-F: Specifies what needs to be displayed, that is, one paragraph after the separation
[Email protected]:/home/linlin/linlin/text# cat Sort.test
12312:213:12312:2341
1232:231:2131:1231
12:23124:2131:124
12314:1234:121:12341
12441:3543:241:4
[Email protected]:/home/linlin/linlin/text# cut-d:-f3 sort.test
12312
2131
2131
121
241
Join: Connection Display
Sort: After sorting the files in the display, the default is based on the sort ascending order in the ASCII code
Common options:
-N: Sort by numeric size
-R: Descending sort
-T: Specify character delimiter, default to white space
-K (N): Specifies that a part of the file is sorted by standard, and N indicates the segment after the delimiter is split
-F: Ignore character capitalization when sorting
-B: Ignore whitespace at the beginning
[Email protected]:/home/linlin/linlin/text# sort-n sort.test
12:23124:2131:124
1232:231:2131:1231
12312:213:12312:2341
12314:1234:121:12341
12441:3543:241:4
[Email protected]:/home/linlin/linlin/text# sort-r sort.test
12441:3543:241:4
1232:231:2131:1231
12314:1234:121:12341
12312:213:12312:2341
12:23124:2131:124
[Email protected]:/home/linlin/linlin/text# sort-t:-k3 sort.test
12314:1234:121:12341
12312:213:12312:2341
1232:231:2131:1231
12:23124:2131:124
12441:3543:241:4
Uniq: report omitted rows when displayed or ignore duplicate rows
Duplicate row definition in Linux: Two adjacent rows, and the contents of the two lines are exactly the same
-D: Only duplicate rows are displayed, but duplicate rows are displayed only once
-C: Displays rows and displays the number of repetitions of a row
[Email protected]:/home/linlin/linlin/text# uniq-c uniq.test
1 ASDFG
2 ASDFH
1 1234
[Email protected]:/home/linlin/linlin/text# uniq-d uniq.test
Asdfh
Text statistics:
Wc:word count number of lines of text, number of words, number of bytes
-L: Show only the number of rows
-W: Displays only the number of words
-C: Show only the number of characters
-M: With-C
-L: Displays the maximum number of characters that are included in the longest row
[Email protected]:/home/linlin/linlin/text# wc-l/etc/passwd
42/etc/passwd
Character Processing:
TR: converting or deleting characters
TR [option] Character set 1 character set 2
[Email protected]:~/linlin/test$ tr ' AB ' AB '
Abcd
Abcd
-D: Remove all characters that exist in the character set
[Email protected]:/home/linlin/linlin/text# tr-d ': ' < sort.test
12312213123122341
123223121311231
12231242131124
12314123412112341
1244135432414
Linux text Editing