Linux command for viewing text content

Source: Internet
Author: User
Commands for viewing text content in Linux include multiple commands for viewing text content in Linux, including cat, more, less, head, and tail. The following describes these commands one by one. 1.) cat command: this command is usually used to view text files with a small amount of content. long files will be rolled too fast without any...
Commands for viewing text content in Linux include multiple commands for viewing text content in Linux, including cat, more, less, head, and tail. The following describes these commands one by one. 1) cat command this command is usually used to view text files with a small amount of content. long files cannot be read because they are scrolling too fast. (This command is equivalent to the DOS type command) execute the "A.txt" command under the "rootroot" command. you can specify multiple files or use wildcards to display the content of multiple files in turn. For example, a.txt and B .txt under rootare displayed. The command is as follows: cat/root/A.txt B .txt. In addition, the cat command can also create new files or combine several files into one file. For example: cat> 1.txt, a new 1.txt file www.2cto.com cat A.txt B .txt> 2.txt is created, and A.txt and B .txt are merged into 2.txt cat commands for displaying text content. When option-n is added, row numbers can be added during display. Cat-n 1.txt 2 .) more and less commands are not suitable for cat commands for text files with a large amount of content. As mentioned earlier, cat commands are not readable due to scrolling too fast, you can use the more or less command to view the details. Www.2cto.com ① more command this command displays a screen of text at a time. when the screen is full, stop and print--More-at the bottom of the terminal --, the system also displays the percentage of displayed text in all text. to continue displaying, press enter or space key. This command has a common option-p, which is used to display the screen before the next screen. To exit the more Display, Press q. More command usage: more [-option] file ② less command is more powerful than more command. in addition to more functions, it also supports scrolling up and down the file with the cursor, the wide document can also be horizontally rolled. when it reaches the bottom, the less command will not automatically exit. you need to press q to exit browsing. In addition, to move to a location indicated by the percentage of files, you can specify the number between 0 and 100 and Press p. For example: 50 p www.2cto.com less command usage: less [-option] file 3 .) the head and tail commands are used to view the content in the front part of the file. by default, the content in the first 10 rows is displayed. of course, you can also specify the number of rows to view. Use: The head-n file name tail command is opposite to the head command. it is used to view the content of the last several lines of the file. the default value is the last 10 lines, which is the same as the head command. In addition, the tail command with option-f enables non-stop reading and display of file content, so as to achieve real-time monitoring.
 

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.