Splitting a file into small files

Hi Folks,

Please help me in solving the problem.

I want to write script in order to split a file into small pieces and send it automatically through mail.

Ex. The file name is CALM*.txt . It is around 50 MB. I want to split the file into 20 MB 2-3 smaller files and send (like uuencode) it to some user (like piyush@unix.com)

Kindly help.

assuming the file is a text file, use split to make smaller files, depending upon the average line length, about 25000, 40 character lines per megabyte.

mkdir output
cd output
split -l1000000 ../inputfile
list=`ls x*`
count=1
for file in $list
do
mutt -a $file -s "Part $count" emailaddress
count=`echo $count + 1|bc`
done

Changed the line that was list=`ls` to list=`ls x*` so that this script is not part of the emails

Hi Jgt,

Thanks for the solution , but mutt is not isntalled in my system. I was looking for sending the files through 'uuencode'.... Can you help??

uuencode $file ${file}.txt | mailx -s "Part $count" abc@xyz.com 

Thanks jayan.... I am kind of naive....Can you help me putting it into a script..

Just replace the "mutt" line in my script with jayan_jay's "uuencode..." line.

thanks a lot JJ and jgt....