In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Preface
When large data needs to be uploaded to the server or large log files are downloaded from the server, the transmission will often be interrupted due to network or other reasons and have to be retransmitted. In this case, you can first split the large file into small files and then transfer them in batches, and then merge the files.
1. Split the file
File splitting can use the split command, which supports both text file segmentation and binary file segmentation, while merged files can use the cat command.
1.1 text file segmentation
When you split a text file, you can split it by file size or by the number of lines of text.
Split by file size
When you split a file by file size, you need to specify the split file size with the-C parameter:
$split-C 100m large_file.txt stxt
As shown above, we split the large file large_file.txt by 100m and specify the split file prefix stxt;. When the prefix is not specified, split will automatically name the split file, usually starting with x.
Split by row
Text files can also be split in behavior units, ignoring the file size when split by the number of lines, and specifying the number of lines of the split file with the-l parameter:
$split-l 1000 large_file.txt stxt
1.2 binary file segmentation
Binary file splitting is similar to splitting text files by size, except that the split file size is specified with the-b parameter:
$split-b 100m data.bak sdata
two。 File merging
File merging uses the cat command, and files split in the above ways can be merged using the cat command.
The cat command merges split files:
$cat stxt* > new_file.txt
3. Command format
3.1 split Command description
The split command format is as follows:
Split [options]... [file to be cut [output file prefix]]
Command parameter
-a,-- suffix-length=N uses a suffix of length N (default 2)
-b,-- bytes=SIZE sets the size of the output file. Support unit: m.j.k.
-C,-- line-bytes=SIZE sets the maximum number of lines in the output file. Similar to-b, but try to maintain the integrity of each line
-d,-- numeric-suffixes uses numeric suffixes instead of letters
-l,-- the number of lines of the lines=NUMBER device output file
-- help displays version information
-- version outputs version information
3.2 cat command description
Cat is one of the most frequently used commands under Linux, which describes in detail:
Cat connects the file and prints it to the standard output device
Common usage scenarios for the cat command are:
Display the contents of the file:
$cat filename
Create an empty file:
$cat > filename
File merge:
$cat file1 file2 > file
Summary
The above is the whole content of this article, I hope that the content of this article can bring some help to your study or work, if you have any questions, you can leave a message and exchange, 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.