In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to view the relevant commands about the contents of the Linux file. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
Use the following command on the Linux system to view the contents of the file:
Cat 、 tac 、 nl 、 more 、 less 、 head 、 tail
You can use man [commands] to view the documentation for each command, such as man cp.
Cat
Display the contents of the file from the first line
Syntax:
Cat [- AbEnTv]
Options and parameters:
-A: an integration option equivalent to-vET, which lists some special characters instead of whitespace
-b: list the line number, display the line number only for non-blank lines, and the blank lines are not marked with line numbers!
-E: displays the line break byte $at the end
-n: print the departure number, along with a blank line, which is different from the option of-b
-T: display the [tab] button as ^ I
-v: list some unrecognizable special characters
Check the contents of the / etc/issue file:
[root@www ~] # cat / etc/issueCentOS release 6.4 (Final) Kernel\ r on an\ m
Tac
Tac is the opposite of the cat command, and the contents of the file are displayed from the last line. You can see that tac is written backwards for cat! Such as:
[root@www ~] # tac / etc/issueKernel\ r on an\ mCentOS release 6.4 (Final)
Nl
Show line number
Syntax:
Nl [- bnw] file
Options and parameters:
-b: there are two main ways to specify a line number:
-b a: indicates that the line number is also listed regardless of whether it is blank or not (similar to cat-n)
-b t: if there is a blank line, do not list the line number on the blank line (default)
-n: there are three main ways to list the line number representation:
-n ln: the line number is displayed on the far left side of the screen
-n rn: the line number is displayed on the rightmost side of your field without adding 0
-n rz: the line number is displayed on the rightmost side of your field, plus 0
-w: the number of digits occupied by the line number field.
Example 1: list the contents of / etc/issue with nl
[root@www ~] # nl / etc/issue 1 CentOS release 6.4 (Final) 2 Kernel\ r on an\ m
More
Turn one page at a time
[root@www ~] # more / etc/man_db.config## Generated automatically from man.conf.in by the# configure script.## man.conf from man-1.6d.... (omitted in the middle)....-More-- (28%)
During the run of the more program, there are several buttons you can press:
Blank key (space): for turning down one page
Enter: stands for turning down "one line"
/ string: means to search down the keyword "string" in the content displayed.
: F: immediately show the file name and the number of lines currently displayed
Q: the representative immediately leaves the more and no longer displays the contents of the file.
B or [ctrl]-b: means to turn the page back, but this action is only useful for files, not for pipelines.
Less
Page by page, the following example outputs the contents of the / etc/man.config file:
[root@www ~] # less / etc/man.config## Generated automatically from man.conf.in by the# configure script.## man.conf from man-1.6d.... (omitted in the middle):
The commands that can be entered during less runtime are:
Blank key: turn down one page
[pagedown]: turn a page down
[pageup]: turn a page up
/ string: the function of searching down for "string"
? String: the function of searching up for "string"
N: repeat the previous search (and / or? Related!)
N: reverse repetition of the previous search (and / or? Related!)
Q: leave the less program
Head
Take out the first few lines of the file
Syntax:
Head [- n number] file
Options and parameters:
-n: followed by a number, which means how many lines are displayed
[root@www ~] # head / etc/man.config
By default, the first 10 lines are displayed! To display the first 20 lines, you have to do this:
[root@www ~] # head-n 20 / etc/man.config
Tail
Take out the last few lines of the file
Syntax:
Tail [- n number] file
Options and parameters:
-n: followed by a number, which means how many lines are displayed
-f: indicates that the file name followed by continuous detection will not end tail detection until [ctrl]-c is pressed.
[root@www ~] # tail / etc/man.config# displays the last ten lines by default! To display the last 20 lines, you have to go like this: [root@www] # tail-n 20 / etc/man.config what is the Linux system Linux is a free-to-use and freely distributed UNIX-like operating system, is a POSIX-based multi-user, multi-tasking, multi-threaded and multi-CPU operating system, using Linux to run major Unix tools, applications, and network protocols.
After reading the above, do you have any further understanding of how to view the relevant commands in the Linux file? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.