Firstly, we need to have mencoder installed.
sudo apt-get install mencoder mplayer
Now, lets assume that we have two avi files called f1.avi and f2.avi.
The first step is to join the files together;
cat f1.avi f2.avi > f1f2.avi
If you have more than two files simply include them all (in the correct order of course)
cat f1.avi f2.avi f3.avi > f1f2f3.avi
Next, we need to ensure that the audio syncing has not been messed up;
mencoder -forceidx -oac copy -ovc copy f1f2.avi -o final.avi