How To Delete Carriage Returns and Linefeeds (CRLF) Using Sed on Unix/Linux/OSX

Fig.01: cat and sed command in action to delete carriage returns and linefeeds (CRLF)

Fig.01: cat and sed command in action to delete carriage returns and linefeeds (CRLF)

Use the cat command to see CRLF on Unix or Linux:
cat -v filename
Sample outputs:

This is a test file.^M
^M
She says, "We've gotta hold on to what we've got.^M
It doesn't make a difference if we make it or not.^M
We've got each other and that's a lot.^M
For love we'll give it a shot."^M

To delete carriage returns the sed command:

The syntax:
sed 's/\r$//g' input > output
sed -i 's/\r$//g' input
cat -v input

OR
sed 's/.$//g' input > output
sed 's/\x0D$//g' input > output

To delete a linefeed (LF) with sed command:

The syntax is:
sed ':a;N;$!ba;s/\n//g' input > output

Examples and usage: sed Delete / Remove ^M Carriage Return (Line Feed / CRLF) on Linux or Unix