Occasionally, there is a need to convert a UNIX formatted file (or files) to a DOS format and vice versa. As a unix system administrator, I’ve performed this task many times. In the examples below, I’ll demonstrate the task singly and then multiple using an inline loop.
Convert an ISO Standard formatted file to DOS standard formatted file
# csh
# unix2dos filenameUNIX > filenameDOS
# foreach i (*)
? unix2dos $i > $i.$$
? mv $i.$$ $i
?end
Convert a DOS formatted file to ISO standard formatted file
# dos2unix filenameDOS > filenameUNIX
# foreach i (*)
? dos2unix $i > $i.$$
? mv $i.$$ $i
?end
1 comment:
Oldskool:
tr -d '\r' < file > clean-file
Post a Comment