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.
The text files under UNIX end their line with the symbol "\n" (called Line Feed and noted LF, ASCII code = 0A).
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
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
sed 's/$/\r/' file