Quote:
Originally Posted by hydrurga
An explanation of sorts can be found here:
|
Yes, in this explanation
rush's solution gives a more simplified version, which I can accept.
My successful trial:
Code:
$ Ch16-23UnixToDOS_TextConv.sh ./A.TXT
Original UNIX text file is "./A.TXT".
Converted DOS text file is "./A.TXT.DOS".
$ od A.TXT.DOS
000000 S e e sp t h e sp d o g cr nl s e e
53 65 65 20 74 68 65 20 64 6f 67 0d 0a 73 65 65
000010 sp t h e sp s o c k s cr nl s e e sp
20 74 68 65 20 73 6f 63 6b 73 0d 0a 73 65 65 20
000020 t h e sp b i r d cr nl s e e sp t h
74 68 65 20 62 69 72 64 0d 0a 73 65 65 20 74 68
000030 e sp c o a l cr nl s e e sp D o n a
65 20 63 6f 61 6c 0d 0a 73 65 65 20 44 6f 6e 61
000040 l d sp T r u m p cr nl
6c 64 20 54 72 75 6d 70 0d 0a
Now I can make a simple script to be able to convert a UNIX-formatted text file into DOS-formatted text file, mainly through the following modifications to e23's code:
Code:
NEWFILENAME=$1.dos
sed 's/$/\r/' < $1 > $NEWFILENAME
All Complete!
Learning hands on can be as messy and changing your petrol-based automobile's oil, or fixing your man-powered bicycle. But I have made certain improvements as summed up by
rtmistler below.
The thicker and deeper the mud, the more beautiful the lotus blooms. May we all live like the lotus: at ease in muddy water.