Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to split and merge in linux

Shulou Source: shulou.com Published: 2022-06-01 05:27:07 10月03日 Update

This article mainly introduces how to split and merge in linux, with a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Operational scenario 1: the difficulty of using split to split files ★ demo release Fedora 32 involves the command split

Split 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 siz

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 [option] [size] [File to be split] [prefix after split (optional)]

Take split debian-live-10.5.0-amd64-lxqt.iso (approx. 2.4 GB) 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: using cat to merge files is difficult for ★ demo release Fedora 32 involves commands cat, Diff

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.

Merge split files

Using cat to merge files can be in the format of cat [file.] > [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 uses diff to validate files

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. Thank you for reading this article carefully. I hope the article "how to split and merge in linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: File size binary command text article output situation utility at the same time scenario format environment program system difficulty release support demonstration verification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Redmi Xiaomi Apple vpn