In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Tail command in linux-used to view the contents of the file
The most basic are cat, more and less.
1. If you only want to see the first five lines of the file, you can use the head command, such as:
Head-5 / etc/passwd
two。 If you want to view the last 10 lines of the file, use the tail command, such as:
Tail-10 / etc/passwd or tail-n 10 / etc/passwd
Tail-f / var/log/messages
The parameter-f causes tail to keep reading the latest content, so that the effect of real-time monitoring is terminated with Ctrl+c!
3. To view the middle section of the file, you can use the sed command, such as:
Sed-n'5 10p'/ etc/passwd
This way you can only look at lines 5 through 10 of the file.
Tail syntax format:
Tail [- f] [- c Number |-n Number |-m Number |-b Number |-k Number] [File]
Or
Tail [- r] [- n Number] [File]
Instructions for use:
The tail command writes the file specified by the File parameter to standard output from the specified point. If no file is specified, standard input is used. The Number variable specifies how many cells are written to standard output. The value of the Number variable can be a positive or negative integer. If the value is preceded by a + (plus sign), the file is written to standard output starting with the number of cells specified at the beginning of the file. If the value is preceded by a-(minus sign), the file is written to standard output starting with the number of cells specified at the end of the file. If the value is not preceded by a + (plus sign) or-(minus sign), the file is read from the unit number specified at the end of the file.
Main parameters:
-b Number reads the specified file from the 512-byte block location represented by the Number variable.
-c Number reads the specified file from the byte location represented by the Number variable.
-f if the input file is a regular file or if the File parameter specifies FIFO, the tail command does not terminate after copying the last specified unit of the input file, but continues to read and copy additional units from the input file (when those units are available). If no File parameter is specified and the standard input is a pipe, the-f flag is ignored. The tail-f command can be used to monitor the growth of files being written by another process.
-k Number reads the specified file from the location of the 1KB block represented by the Number variable.
-m Number reads the specified file from the multibyte character position represented by the Number variable. Use this flag to provide consistent results in single-byte and double-byte character code set environments.
-n Number reads the specified file from the first or last line location, represented by the symbol of the Number variable (+ or-or none), and shifted by the line number Number.
-r displays the output in reverse order from the end of the file. The default value of the-r flag is to display the entire file in reverse order.
If the file is larger than 20480 bytes, the-r flag displays only the last 20480 bytes. The-r flag is valid only with the-n flag. Otherwise, it will be ignored.
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.