This question already has an answer here:
I have been using d2u
to convert line endings. After installing Puppy Linux I
noticed that it does not come with d2u
, but dos2unix
. Then I noticed that
Ubuntu is missing both by default.
What is another way to convert line endings?
Doing this with POSIX is tricky:
POSIX Sed does not support
\r
or\15
. Even if it did, the in place option-i
is not POSIXPOSIX Awk does support
\r
and\15
, however the-i inplace
option is not POSIXd2u and dos2unix are not POSIX utilities, but ex is
POSIX ex does not support
\r
,\15
,\n
or\12
To remove carriage returns:
To add carriage returns:
Some options:
Using
tr
OR
Using
perl
Using
sed
OR
To obtain
^M
, you have to typeCTRL-V
and thenCTRL-M
.