Joining Files the Linux Way

The Concatenate Command – cat

You can use the cat command to join files together without using an editor. To do this, type cat, the names of the files you want to join together, and then redirect the output into a new file.

For example, if you want to join together file1, file2, and file3 into a file called allfiles, you could type:

cat file1 file2 file3 > allfiles

The nice thing about the cat command is it can join nearly any type of file as long as the format of the files are the same. For example you can join avi files if they are in the same format, e.g. stop motion video taken by a web cam.

However, there are some types of files which are better left for more specialist programs to join, and one of these file types is created using a cross platform program called hjsplit For these file lxsplit is a more reliable option, although a Java version of hjsplit does exist for Linux, the former is easier an quicker!

lxsplit for Joining Split (e.g. hjsplit) Files

To Join a file split with HJSPLIT or lxsplit enter from the directory where the file is located

lxsplit -j <filename>.001

A new file consisting of all the split parts will be created called <filename>

If you have not already guessed, the -j is short for Join!

Using lxsplit for Splitting Files

There are many reasons why you may wish to split a file e.g. your e-mail system has a 10Mb file attachment limit and you want to send a 30Mb file.

To split a 30Mb file in to 10Mb sections you would enter:

lxsplit -s <largefilename> 10M

where <largefilename> is the name of the 30Mb file.

A Manual page exists for lxsplit and this can be displayed in Terminal by entering

man lxsplit

Powered by Bilbo Blogger


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s