Convert windows file to unix on old server without dos2unix

conversion

I use an old server without dos2unix and I would like to convert windows files to unix files. I am unfortunately not the admin so I can't install dos2unix. The tr method seems to be the only one that works.

cp script _p4 && tr -d '\r' < _p4 > script && rm _p4

Are there any easier methods to do this? I have a really hard time either remembering this or searching for this.

Best Answer

If you have GNU sed you can do this:

sed -i 's/\x0D$//' script

Where "x0D" is the ASCII code for \r.

Related Question