- unix2dos
-
unix2dos (sometimes named todos or u2d) is a Unix tool to convert an ASCII text file from Unix format (line break) to DOS format (carriage return and line break) and vice versa. When invoked as unix2dos the program will convert a Unix text file to DOS format, when invoked as dos2unix it will convert a DOS text file to UNIX format. [1]
The tofrodos package provides this functionality to Linux, Mac OSX, and can be downloaded for windows.[2]
Contents
Usage
unix2dos [-p] [file]
- -p
- Access and modification time of the original file are preserved.
- file
- File to convert
Alternatives to unix2dos conversion
Similar results can be achieved with different unix tools to change the trailing new line '\n' to combination of carriage return and new line characters '\r\n' for example with the sed or perl in-line editing:
perl -i -p -e 's/\n/\r\n/' file sed -i -e 's/$/\r/' file
For opposite conversion (dos2unix) it is possible to alternatively use for example the utility tr to change a text file from Windows or OS X into a Linux text file by using the -d '\r' flag to remove carriage returns:
tr -d '\r' < file > file2 perl -i -p -e 's/\r//' file sed -i -e 's/\r//' file
See also
References
- ^ A practical guide to Linux. Mark G. Sobell ISBN 0-13-147823-0 Page 55
- ^ "tofrodos". http://www.thefreecountry.com/tofrodos/. Retrieved 2009-10-05.
External links
- Tofrodos - software that provides dos2unix and unix2dos
This Unix-related article is a stub. You can help Wikipedia by expanding it. - -p