Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Free Guide: Linux from Scratch
Linux from Scratch describes the process of creating your own Linux system from scratch from an already installed Linux distribution, using nothing but the source code of software that you need.
This 318 page eBook provides readers with the background and instruction to design and build custom Linux systems. The resulting system will be compiled completely from the source code, and the user will be able to specify where, why, and how programs are installed. This eBook allows readers to fully customize Linux systems to their own needs and allows users more control over their system.
Click Here to receive the Linux from Scratch Guide absolutely free.
By Kristijan at 2004-07-23 04:37
=====================
Split and Reassemble files
=====================
There always comes a time, where you wish that file was only a few kilobytes/megabytes smaller. Wether it be so it can fit onto your floppy disk, CDR etc, or so you can meet the attachment limit on an e-mail server. This isn't really a command that you would use everyday, but it might come in handy.
Splitting the file (split)
=================
Now, for this example I will use the file 'karaoke.mp3' which is 13M
Code:
kristijan@slackware testing$ ls -lh
total 13M
-rw-rw-r-- 1 kristijan users 13M Jul 23 18:18 karaoke.mp3
Just say we wanted to e-mail this file to a friend, but the e-mail server only allowed a maximum of 2M attachments.
(Note** I like to play safe, so I will make my chunks of data 1.9M)
1.9 x 1024 = 1945.6
(Note** To play safe once again, I will leave out the decimal and just use 1945)
The command that we will use is $ split -b 1945k karaoke.mp3
OK, what we have now done is told 'split' to use bytes per output file (-b). For more information and arguments on split, view the man pages (man split). Split how now 'split' karaoke.mp3 into 7 smaller files named 'xaa', 'xab', 'xac' etc, which are all under 2M in size.
These files now meet the e-mail server's attachment limit and can be sent.
Recreating the file (cat)
==================
Recreation of the karaoke.mp3 is even easier. For this, we will be using 'cat'. See the man pages for more information on 'cat' (man cat).
The command that we will use is $ cat xa* > karaoke-restored.mp3
(Note** Before removing the original file, I recommend that you make a backup of it)
I'd suggest to take the md5sum of the original file, to send it along as "karaoke.mp3-md5sum"-text file and compare the newly created file's md5sum with the original, just to make sure nothing happened during emailing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
I'd suggest to take the md5sum of the original file, to send it along as "karaoke.mp3-md5sum"-text file and compare the newly created file's md5sum with the original, just to make sure nothing happened during emailing.