Windows uses carriage return and line feed for newline:
Unix only uses Line feed for newline:
In conclusion, simply replace every occurence of \n by \r\n. Both unix2dos and dos2unix are not by default available on Mac OSX.
Fortunately, you can simply use Perl or sed to do the job:
sed -e 's/$/\r/' infile > outfile # UNIX to DOS (adding CRs) sed -e 's/\r$//' infile > outfile # DOS to UNIX (removing CRs) perl -pe 's/\r\n|\n|\r/\r\n/g' infile > outfile # Convert to DOS perl -pe 's/\r\n|\n|\r/\n/g' infile > outfile # Convert to UNIX perl -pe 's/\r\n|\n|\r/\r/g' infile > outfile # Convert to old Mac