I recently e-mailed myself a unix script from my Linux laptop to by OSX laptop. Somewhere along the line, the file was converted to DOS style line endings. Here's what I did to put the line endings back:
vi filename :set ff=unix :w :q
If you want to convert the file TO a DOS style file, use "dos" instead of "unix".