In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to split large log files under Linux, which is very detailed and has a certain reference value. Interested friends must read it!
How to split
Split orders to play.
Split by number of rows
Suppose the file test.txt has multiple lines, and every 2 lines are split into a file, and you can use the-l parameter:
$split-l 2 test.txt $ls-al-rw-r--r-- 1 root root 32 Aug 31 16:55 test.txt-rw-r--r-- 1 root root 20 Aug 31 16:55 xaa-rw-r--r-- 1 root root 12 Aug 31 16:55 xab
If you take a closer look, it is difficult to describe the file name after the split.
Could you name it properly?
Canonical naming
Use the-d parameter to use a number as a new file suffix:
$split-l 2 test.txt-d $ls test.txt x00 x01 x02
You can also specify the length of the suffix number with-a (the default is 2):
$split-l 2 test.txt-d-a 4$ ls test.txt x0000 x0001 x0002
However, the first x is out of order. We can also specify a prefix, such as test:
$split-l 2 test.txt-d-a 4 test $ls test0000 test0001 test0002 test.txt
And you can also start with a specified numeric subscript and use-- numeric-suffixes, for example, from 0004:
$split-- numeric-suffixes=4 test.txt-a 4-l 2 test.txt x0004 x0005
Split by size
Use the-b parameter to split by size, in bytes:
$split-b 10 test.txt
Of course, k (kilobytes) and m (megabytes) can also be used. That is:
$split-b 10k test.txt
Split into a specified number of files
You can use the-n parameter, such as split into 3 files regardless of size and number of lines:
$split-n 4 test.txt $test.txt xaa xab xac xad
Other methods
Of course, typed log files can be opened instead of creating temporary files (for example, vim opens a file to create a temporary file). Instead, you can use commands such as more,tail to view some of the contents.
The above is all the contents of the article "how to split large log files under Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.