This article mainly introduces several commonly used text view commands and text processing commands.
First introduce the text view command
Cat: Used to connect files and display
Note: When there is only one file, it is used to view the contents of the file; when there are multiple files, the cat command connects the files and displays them together.
Syntax format: cat [option] FILE ...
-N: Displays the line number when the content is displayed
-E: Displays the Terminator $ character for each line (not shown by default)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/2D/1D/wKioL1OUPACyzhwhAAGMEGwDqnY399.jpg "title=" Cat.png "alt=" Wkiol1oupacyzhwhaagmegwdqny399.jpg "/>
TAC: It is also used to display the contents of a file, except that he displays the contents of the file upside down, as opposed to cat
-N: Show line numbers
-E: Displays the Terminator $ at the end of each line
Split-screen Operation commands
More and less
Usage: Some files have more content, may need to turn a lot of pages, if you use the cat or TAC command to view, because the number of file pages too many, will cause you want to view the command to see, so in order to facilitate the user's reading and viewing, so you can use the more and less command to view.
Syntax format: more|less FILE
More and less syntax are roughly the same, except that less can be manipulated forward.
The usage of less is almost the same as the manual operation of Man, which is no longer described here.
View file header and tail commands
Head: Used to view the number of lines in front of a file
Syntax format: head [option] FILE
-N: Displays the number of lines (the first 10 lines are displayed by default)
Tail: Viewing the last few lines of a file
Syntax format: tail [option] FILE
-N: The last 10 lines of the file are displayed by default
-F: Look at the end of the file without exiting, waiting to display new content appended to this file
Processing commands for text
Cut: Displays some of the information in each line of the file
Syntax format: cut [option] FILE ...
-d ' delimiter ': Specifies a separator, default is a space, usually used with-f
-FNUM1 [, num2]: Go to the first few fields after cutting, if there are multiple, separated by commas. Usually used in conjunction with-D
The following example:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/2D/1F/wKiom1OUXdLwMKi2AAGiHTJ9UQ4979.jpg "title=" Cut.png "alt=" Wkiom1ouxdlwmki2aagihtj9uq4979.jpg "/>
Text Sort command: sort
Description: The sort command is sorted in ascending order by default based on ASCII code.
Syntax format: sort [option] FILE.
-N: Sort by numeric size
-R: Reverse order
-T ' delimiter ': Specify delimiter
-K NUM1 [, num2]: Sorting According to the specified field
For example:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/2D/20/wKioL1OUY2rjgxUYAAHKcMqFwN4912.jpg "title=" Sort.png "alt=" Wkiol1ouy2rjgxuyaahkcmqfwn4912.jpg "/>
-U: The same row is displayed only once (the adjacent rows are called duplicates after sorting)
-F: Sorting is case insensitive
Examples are as follows:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/2D/20/wKioL1OUZVayM1_GAAEAFSwujTA919.jpg "title=" Sort2.png "alt=" Wkiol1ouzvaym1_gaaeafswujta919.jpg "/>
Uniq: Show only the same rows
Syntax format uniq [option] [input [output]]
[input [Output]]: can be the content of the standard input to filter, and then redirect to the standard input
-D: Show only a repeating line ( description: Only adjacent rows are called duplicate rows )
-D: Show all rows that are duplicated
-C: Displays the number of occurrences of some rows
Examples are as follows:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/2D/20/wKioL1OUaGrAUkAXAAGXXo44WWE662.jpg "title=" Uniq.png "alt=" Wkiol1ouagraukaxaagxxo44wwe662.jpg "/>
Text Statistics Command WC
Syntax format: WC [option] FILE ...
-L: Count How many lines there are
-W: Shows the number of words
-C: Show Total bytes
-M: Displays the total number of characters
-L: Displays the maximum number of characters for the longest line
Examples are as follows:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/2D/20/wKioL1OUbCrzAG-EAAGU_l1J2Ic871.jpg "title=" wc.png "alt=" Wkiol1oubcrzag-eaagu_l1j2ic871.jpg "/>
Character processing commands
Syntax format TR [option] SET1 [SET2]
Set: Refers to a character set
TR: Can * * * character or character conversion
-d:*** the specified character
Examples such as the following
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/2D/20/wKioL1OUbkKSNiiOAAE59tC3F0g852.jpg "title=" tr.png "alt=" Wkiol1oubkksniioaae59tc3f0g852.jpg "/>
This article from the "Linux Learning Path" blog, declined reprint!