UNIX file content display commands cat, more, less, Head, and tail

Source: Internet
Author: User

■ Cat command

Displays the file content.

Assume that the F. Java file exists. Each time you input a line, a blank line is displayed ,:

● Default options

:

●-A Option

Displays the file content, ^ I mark (Tab key), and $ mark (line break ). :

●-B Option

The text line number is displayed. Empty rows are not included. :

●-E Option

Show text lines and line feed $. :

●-E Option

The $ symbol is displayed at the end of each line. : Same as-e option.

●-N Option

Line numbers are displayed on each line, and empty rows are also included. :

●-T Option

Display the tab key and mark it as ^ I.

●-S option

When there is a blank space larger than two rows, only one row is displayed for compression.

Suppose f. Java is as follows:

The-s option is displayed as follows:

■ More command

Assume that the F. Java file exists and there is no blank line.

● Default options

:

●-Num Option

Specifies an integer, such as num = 2, indicating the number of lines of text displayed at one time on the current screen. For example, execute more-2 F. Java ,:

It can be seen that only two lines of text are displayed. Click the Space key to continue.

●-D option

When the file content cannot be displayed on a screen, the following button is displayed: Press space to continue, 'q' to quit. :

●-Num Option

● +/Option

You can enter a matched string after the slash (+/). If the specified file does not exist, a prompt is displayed. Otherwise, the row of the corresponding string is displayed.

The string out exists in the F. Java file. If you execute more +/out f. Java, the F. Java content is directly displayed.

If the astring does not exist in the F. Java file ,:

Click the Space key to display the content of the f. Java file.

■ Less command

The less command is similar to the more command, but the less command can be the same as the VI editor. For example, enter the following command:

Less hello. C f. Java

Enter two files to enter the mode:

The following line shows that the next file is F. java. You can directly type "N" to display the content of the f. Java file ,:

In this mode, enter the command: P to view the previous file hello. C.

For the less command, you can directly enter the man less command to view the help manual.

■ Head command

● Default options

If no option is specified, for example, if head f. Java is executed, all contents of the f. Java file are displayed.

●-N Option

Displays the first n rows of the specified file. N is an integer. :

The first two lines of the f. Java file are displayed.

In addition, the header information of multiple files can be displayed (specify the first n rows ),:

■ Tail command

● Default options

If no options are specified, for example, if tail F. Java is executed, all contents of the f. Java file are displayed.

●-N Option

The last n rows of the specified file are displayed. N is an integer. :

The last four lines of the f. Java file are displayed.

In addition, the tail information of multiple files can be displayed (the last n rows are specified ),:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.