In Linux, the commands cat, more, and less can all be used to view file contents. cat displays the contents of the entire file at once, and can also connect multiple files for display. It is often used in conjunction with the redirection symbol and is suitable for situations where the file content is small. more and less are generally used to display file content that exceeds one screen, and provide page turning functions. Less is more powerful than more, providing commands such as page turning, jumping, and searching. As we all know, the commands cat, more, and less in Linux can all be used to view file contents. The main differences are: cat displays the contents of an entire file at once, and can also connect multiple files for display. It is often used in conjunction with the redirection symbol and is suitable for situations where the file content is small; More and less are generally used to display file contents that exceed one screen and provide page turning function. More is more powerful than cat and provides paging display function. Less is more powerful than more and provides commands such as page turning, jumping, and searching. And both more and less support: use space to display the next page, and press b to display the previous page. The following describes these three commands in detail. more file content or output viewing tool: More is one of our most commonly used tools. It is most commonly used to display the output content, and then display it in pages according to the size of the window, and it can also prompt the percentage of the file; Less View file content tool: The less tool is also a tool for paging files or other outputs. It can be said to be an orthodox Linux tool for viewing file contents. It is extremely powerful. If you are a beginner, I recommend that you use less. Since there are too many contents in less, we will introduce the most commonly used ones. In Linux, the commands cat, more, and less can all be used to view file contents. cat displays the contents of the entire file at once, and can also connect multiple files for display. It is often used in conjunction with the redirection symbol and is suitable for situations where the file content is small. more and less are generally used to display file content that exceeds one screen, and provide page turning functions. Less is more powerful than more, providing commands such as page turning, jumping, and searching. cat The cat command displays the contents of the entire file from top to bottom on the screen. 1. Command format 2. Command function Write [file] or standard input to standard output. Cat has three main functions: 1). Display the entire file at once: cat filename 2). Create a file from the keyboard: cat > filename You can only create new files, you cannot edit existing files. 3). Merge several files into one file: cat file1 file2 > file 3. Common parameter list
more The more command will display the content page by page, making it easier for users to read page by page. The most basic command is to press the space key to go to the next page, and press the b key to go back one page. It also has a search string function. The more command reads the file from front to back, so the entire file is loaded at startup. 1. Command format 2. Command function The more command has the same function as cat, which is to view the contents of a file. However, the difference is that more can view the contents of a file by page and also supports functions such as direct line jump. 3. Common parameter list
4. Common operation commands
less The less tool is also a tool for paging files or other outputs. It can be said to be an orthodox Linux tool for viewing file contents, and its functions are extremely powerful. The usage of less is more flexible than that of more. When using more, we have no way to flip forward, we can only look backward. But if we use less, we can use the functions of the [pageup] [pagedown] keys to flip forward and backward, which makes it easier to view the contents of a file! In addition, less has more search functions, not only can you search downwards, but you can also search upwards. 1. Command format: 2. Function: less is similar to more, but with less you can browse the file at will, while more can only move forward but not backward, and less does not load the entire file before viewing it. 3. Command parameters:
For example, when we display the contents of /etc/profile, we want it to display line numbers. [root@localhost ~]# less -N /etc/profile Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: MYSQL subquery and nested query optimization example analysis
>>: js canvas realizes circular water animation
Permissions and database design User Management U...
Related articles: Beginners learn some HTML tags ...
1. First stop the mysql service As an administrat...
Taking Windows as an example, Linux is actually t...
MySQL transaction support is not bound to the MyS...
Use the for loop to import the zabbix image into ...
Table of contents Makefile Makefile naming and ru...
Preface Today I installed MySQL and found that th...
Background: Linux server file upload and download...
1. CPU utilization sar -p (view all day) sar -u 1...
When applying docker containers, we often mount t...
I think the carousel is a relatively important po...
Forwarding between two different servers Enable p...
nginx installation Ensure that the virtual machin...
1. Trash or Classic? Web technology updates very ...