Split and Merge file using dd command

Split and Merge file using dd command

dd command is one of the powerful utility in Linux and should be in every hacker's arsenal. dd command is used to manipulate binary files directly. dd is the tool used to write disk headers, boot records. The command is mostly used to copy / clone / backup / restore entire hard disk or partitions. Any Wrong usage of the command can lead to destroying of file or entire hard disk as it deals directly with the binary data. The command is widely misused to quickly trashing files or partitions.

I was curious to find out how dd command can be used to split and merge files. I wanted to split a given file to fixed size chunk and then on the other end try to put the files back together to create the original file. So here is bash script I came up with to achieve this.



The above script can be used to split and merge any type of files.

Splitting files

The files can be split into chunks by passing -b or --split flag to the script. following is the example usage for splitting files

 $ ./split_merge_file.sh --split --source [path_to_file] --destination [destination_path] --prefix split

The prefix argument is used to specify a prefix that is added to the split files. This prefix is later used in merge command to fetch all the parts of the file.

Merging files

Merge the file parts back to single file using --merge flag in the script.

 $ ./split_merge_file.sh --merge --source [path_to_split_files] --destination [destination_directory] --prefix split


Awesome Dev

Awesome Dev

I am a programming enthusiast. I have a proven track record on translating complex business ideas into working implementations. Software development is not just my career but its my hobby.


You may also like

    Comments powered by Disqus