Linux file view command

Time:2020-10-18

File view command

 

 

1. Cat: displays the contents of the file from the first line

Usage: cat file or file path

For example: cat ifcfg-eth0 or cat / etc / sysconfig / network scripts / ifcfg-eth0

Parameters:

  • -A: The integration option equivalent to – vt can list some special characters instead of blanks;

  • -b: List the line number, only display the line number for the non blank line, and do not mark the line number for the blank line!

  • -E: Display the end broken line byte $;

  • -n: Print out the line number, and the blank line will also have line number, which is different from the option of – B;

  • -T: Display the [tab] button as ^ I;

  • -v: List some special characters that you can’t see

 

 

 

2. TAC is displayed from the last line

Usage: TAC file or file path

For example: TAC ifcfg-eth0 or TAC / etc / sysconfig / network scripts / ifcfg-eth0

 

 

 

3. NL sequential output line number

Usage: NL file

For example: NL ifcfg-eth0

Parameters:

  • -b: There are two ways to specify the line number: – B A: it means that no matter whether it is a blank line, the line number is also listed (similar to cat – n); – B T: if there is a blank line, do not list the line number of the empty line (default value);

  • -n: There are three main methods to list the line number representation: – N ln: the line number is displayed on the left most side of the screen; – N RN: the line number is displayed on the right most side of the field without adding 0; – N RZ: the line number is displayed on the right most side of the field, and 0 is added;

  • -w: The number of digits occupied by the line number field.

 

 

 

4. Page by page

How to use: more file

For example: more ifcfg-eth0

Available keys:

  • Space: represents a page down;

  • Enter: to turn down “one line”;

  • /This keyword represents the content of the search string;

  • : F: the file name and the number of lines currently displayed will be displayed immediately;

  • q: The representative immediately leaves more and no longer displays the contents of the file.

  • B or [Ctrl] – B: to page back, but this action is only useful for files, not for pipelines.

 

 

 

5. Page by page, you can turn pages forward!

Usage: less file

For example:less ifcfg-eth0

Available keys:

  • Blank key: scroll down one page;

  • [pagedown]: page down;

  • [pageup]: page up;

  • /String: the function of searching down “string”;

  • ? string: the function of searching for “string” up;

  • n: Repeat the previous search (related to / or! )

  • N: Repeat the previous search in reverse! )

  • q: Leave the less program;

 

 

 

6. Head only looks at the first few lines

Usage: head – N digital file name

For example: head – N 20 – ifcfg – eth0 view the first 20 lines of the file

 

 

7. Tail only looks at the last few lines of the file

Usage: Tail – N digital file

For example: Tail – N 20 – ifcfg – eth0 to view the last 20 lines of the file