Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does linux view text content

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to view text content in linux". In daily operation, I believe many people have doubts about how to view text content in linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to view text content in linux". Next, please follow the editor to study!

Linux can view the content of the text, it has a variety of built-in commands: 1, cat, you can display content from the first line; 2, tac, you can display content from the last line; 3, more, you can display content one page after another; 4, head, you can view the content of the specified number of lines at the beginning of the text; 5, tail, you can view the lines at the end of the text, and so on.

The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

Under Linux, you can use some commands to preview the contents of a text file without having to open it with a text editor.

Linux has a variety of built-in viewing commands. Here are some common text viewing commands:

Cat: display text content from the first line (for less content) tac: display from the last line, it is the reverse order of cat more: page by page display text content (suitable for more content) less: similar to more, but better than more, it can turn the page forward! Head: only look at the first few lines of the text tail: only look at the last few lines of the text nl: display the text content and line number 1, cat command

The cat command is often used to view files with less content. Many people call this command the "kitten" command, but cat is actually an abbreviation for concatenate (continuous), that is, continuous display of text content.

Format: cat [parameter options] [file]

Among them, add the parameter-n to display the number of rows. More parameter options for cat can be viewed by typing man cat. A detailed description of the other commands listed below can also be viewed by entering the man command.

2. Tac command

The tac command is the exact opposite of the cat command and is displayed from the end of the file.

3. More command

The more command is suitable for viewing files with more content. Because he can display the percentage in real time to indicate how much has been read so far.

Format: more [parameter options] [file]

You can use the spacebar or enter to scroll down the page to see the following content.

4. Less command

Less is also suitable for viewing files with more content. Less is more flexible than more because less can turn pages up and down. Press the PgUp key on the keyboard to turn the page up, press PgDn to turn the page down. However, the less command does not show the percentage of current reading in real time.

Format: less [parameter options] [file] 5, head command

The head command is used to view the first n lines of a file. Such as using a command

Head-n 20 / etc/profile

Look at the first 20 lines of the profile file in the / etc directory:

6. Tail command

The tail command is the opposite of the head command, and the tail command is used to view the contents of the file on the next n lines. Such as:

7. Nl command

The nl command displays the line number as well as the content, much like the cat-n command:

The above commands are some of the text view commands under Linux, although they all have the same function and are used to view the text, but we can choose different commands according to different circumstances to view the file so that we can preview the file better.

At this point, the study on "how to view text content in linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report