How to view linux files Command to view file contents:
1.cat and tac The function of cat is to output the contents of a file continuously on the screen starting from the first line. When the file is large and has many lines, it cannot fit entirely on the screen and only part of the content can be seen. cat syntax: cat [-n] file name (-n: when displaying, output the line number together) The function of tac is to output the content data of the file to the screen in reverse order starting from the last line. We can find that tac is actually cat written in reverse. tac syntax: tac filename. 2. more and less (commonly used) The function of more is to output the file content appropriately starting from the first line according to the size of the output window. When one page cannot be fully output, you can use the "Enter key" to turn down the line and the "Space key" to turn down the page. To exit the viewing page, press the "q" key. In addition, more can also be used with the pipe symbol "|" (pipe), for example: ls -al | more
The function of less is similar to that of more, but you cannot turn pages forward using more, you can only turn pages backward. In less, you can use the [pageup] and [pagedown] keys to turn pages forward and backward, which seems more convenient. The syntax of less is: less file name Less also has a function that allows you to search for the content you want in the file. Suppose you want to find the weblogic string in the passwd file, you can do it like this: [root@redhat etc]# less passwd Then enter: /weblogic Enter At this time, if there is a weblogic string, Linux will display the character in a highlighted manner. To exit the viewing page, press the "q" key. 3. Head and tail Head and tail are usually used when you only need to read the first few lines or the last few lines of a file. The function of head is to display the first few lines of the file The syntax of head is: head [n number] file name (number shows the number of lines) The function of tail is exactly the opposite of head, only the last few lines are displayed The syntax of tail: tail [-n number] file name 4.nl The function of nl is the same as cat -n, which also outputs all the content from the first line and displays the line number. The syntax of nl is: nl filename 5.tailf The tailf command is almost equivalent to tail -f, strictly speaking, it should be more similar to tail --follow=name. It can continue to track files after they are renamed, making it particularly suitable for following the growth of a log file. Unlike tail -f, it does not access the disk file if the file does not grow. Tailf is particularly suitable for tracking log files on portable computers because it saves power by reducing disk access. The tailf command is not a script, but a binary executable file compiled with C code. Some Linux installations do not have this command. The above is all the relevant knowledge points introduced this time. Thank you for your learning and support for 123WORDPRESS.COM. You may also be interested in:
|
<<: MySQL 8.0 error The server requested authentication method unknown to the client solution
>>: A very detailed summary of communication between Vue components
Panther started as a rookie, and I am still a roo...
Step 1: Confirm the architecture of your system d...
When mysql is running normally, it is not difficu...
This article describes how to build a Nexus priva...
After learning the basic operations of Docker, we...
What is a file system We know that storage engine...
Flappy Bird is a very simple little game that eve...
(1) Reduce HTTP requests. (Merge resource files a...
Scenario 1. Maintain a citizen system with a fiel...
ElasticSearch cluster supports動態請求的方式and靜態配置文件to ...
How to display text overflow? What are your needs...
background: The site is separated from the front ...
Table of contents 1. Use 2. Solve the problem of ...
Table of contents rem vw Adapt to third-party UI ...
Introduction to structure and performance HTML st...