^M is the carriage return character, also known as \r.
Windows uses \r\n at the end of each line.
Linux uses \n.
\r can be put in GNU sed expressions.
To convert a Windows text file for Linux the \r's can be removed with sed 's/\r$//'
sed 's/\r$//' dosfile | sed '/^$/d;N;N;N;N;N;N;N;s/\n/ /g' > linuxfile
To convert the file back to the Windows format add \r to the end of each line with
sed 's/$/\r/' linuxfile > dosfile