There are several softwares to convert text files from UNIX or Linux to DOS operating systems and vice-versa. However, it always helps to know the manual conversion.
In shell programming languages like UNIX or Linux the text files conclude with a new line operator "\n" also known as the line feed and its ASCII code is 0A.
A DOS Text file concludes a line by the carriage return or the entry key "\r": its ASCII code is 0D.
The lines in the DOS end with CRLF or with "\r\n". To convert this DOS text into UNIX or Linux , erase the "\r": you can also use ASCII codes if you are using GNU-sed version.
From UNIX to DOS you may add the "\r" or else use GNU-sed notations symbolically, using the ASCII codes.
Though there are (dos2unix and unix2dos) utility programs capable of performing this task, here is a simple tip on how to manually make these features.
Conversion DOS to UNIX / UNIX to DOS
The text files under UNIX end their line with the symbol "\n" (called Line Feed and noted LF, ASCII code = 0A).
Text files under DOS by a "line", end their line with the symbol "\r" (called Carriage Return and noted CR, ASCII 0D). Thus, every line in a DOS file ends with a CRLF sequence, or \r\n.
Conversion from DOS to UNIX
Delete the "\r" (carriage return) at the end of the line.The "\r" is symbolically represented by "^M", which is obtained by the following sequence of keys "CTRL-V" + "CTRL-M":
sed 's/^M$//' file
Note: with the GNU-sed(gsed 3.02.80) version, we can use the ASCII notation:
sed 's/\x0D$//' file
Conversion from UNIX to DOS
Just do the opposite of the previous command, namely (the "^M" being entered in the same way (CTRL-V + CTRL-M)):
sed 's/$/^M/' file
Note: with the GNU-sed(gsed 3.02.80) version, we can use the symbolic notation "\r":
sed 's/$/\r/' file
- Sed -i -e 's/r$//'
- Unix to dos
- What are dos files
- Xvideoservicethief tutorial video converter online > Forum - Video software
- M3u to mp3 converter > Guide
- Date of birth in words converter [solved] > Forum - Excel
- Date of birth in words [solved] > Forum - Excel
- How to compile assembly code: in Linux, Windows, with NASM
- Search in Vim editor: Linux, for words
- Ubuntu remove password: for sudo, for user, for root
- How to disable avahi-daemon: Linux, Ubuntu
- Debian add printer: command line, install cups
- Change password Linux: script, terminal, Samba
- Debian change language: to English, command
- Linux read file line by line: for loop
- Vim autocomplete: C++, command
- Linux display file in reverse order
- How to install htop Linux: Ubtunu, Mint
- Restart network interface: Linux, Ubuntu
- How to create commands in Linux?
- Customize Wine on Linux: download, install, locate theme
- How to resize partition Linux: Gparted, command line
- How to remove the content of a directory: Linux
- How to recover lost admin password in CUPS?
- What is Daemon Log: in Linux
- How to split a file in Linux: split, merge
- Adding space in mount point: to FSTAB
- Delete lines in Linux: SED, commands
- Restoring Linux: from backup, using Tar
- How to uninstall package: in Linux