In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Linux command line how to split and merge files, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Overview of operation
Backing up files often involves the problem of large file transfer. Poor network quality or other problems often lead to transmission interruption and have to be retransmitted. If you first split the large files into multiple small files for transfer, and then merge all the files after the completion of the transfer, you can often improve the transmission experience. We will introduce file split and merge operations under the Linux command line.
Concepts and terminology
Split, as the name implies, is to divide a large file into several smaller files, which can be spliced in order to restore the large file. In general, splitting based on file size is a more common way; however, because text files have the characteristic of the number of lines, in addition to splitting by size, you can also split by number of lines.
Merging is the splicing of several smaller files into a larger file. Usually you just need to connect in order, which is relatively simple.
Typically, validation is required to ensure that the two files before the split and after the merge are the same.
Operational actual combat
Scenario 1: use split to split files
Plit is a file split utility provided by the Linux environment that supports both binary and text files. It is usually built into the system with coreutils and does not need to be installed separately.
Split by size, binary files and text files use different options when splitting by size:
Binaries use the-b option to specify the split file size.
Text files use the-C option to specify the split file size.
The two uses are similar, except that:
Split [options] [size] [File to be split] [prefix after split (optional)] take splitting debian-live-10.5.0-amd64-lxqt.iso (about 2.4GB) by 100MB size as an example:
Split-b 100m debian-live-10.5.0-amd64-lxqt.iso debian-live-
You can see that the original file is split into 25 smaller files, from aa to ay:
Debian-live-aa debian-live-ad debian-live-ag debian-live-aj debian-live-am debian-live-ap debian-live-as debian-live-av debian-live-aydebian-live-ab debian-live-ae debian-live-ah debian-live-ak debian-live-an debian-live-aq debian-live-at debian-live-awdebian-live-ac debian-live-af debian-live-ai debian-live-al debian-live-ao debian-live-ar debian-live-au debian-live-ax
Scenario 2: merge files using cat
Cat is a file connection utility provided by the linux environment that connects files and outputs them to standard output. It is usually built into the system with coreutils and does not need to be installed separately.
It is worth noting that in order to ensure that the merged file is consistent with the original file, you can verify it with the diff command if possible.
Using cat to merge files, you can use cat [files …] > the format of [merged file name], which is valid for both binary and text files.
Take the previous debian-live-aa to debian-live-ay as an example, you can use this command when merging:
> cat debian-live-* > debian-live.iso
You can see that the merged debian-live.iso file is generated under the directory.
Debian-live-aa debian-live-ad debian-live-ag debian-live-aj debian-live-am debian-live-ap debian-live-as debian-live-av debian-live-aydebian-live-ab debian-live-ae debian-live-ah debian-live-ak debian-live-an debian-live-aq debian-live-at debian-live-aw debian-live.isodebian-live-ac debian-live-af debian-live-ai debian-live-al debian-live-ao debian-live-ar debian-live-au debian-live-ax
Validate files using diff
You only need to follow the format of diff [original file] [current file]. If there is no output, it proves that there is no difference between the two files.
Take debian-live-10.5.0-amd64-lxqt.iso and debian-live.iso as an example:
> diff debian-live-10.5.0-amd64-lxqt.iso debian-live.iso > # has no output, which means they are the same. After reading the above, have you mastered how to split and merge files on the Linux command line? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.