2

I have a set of big (>1Gb) binary files which was uploaded to FTP with incorrect line-ending. They contain "0D 0A" where should be "0D". Is there a way in Linux to replace all includings of bytes "0D 0A" to "0D" in command line?

Epsiloncool
  • 1,435
  • 16
  • 39
  • related: [How to convert DOS/Windows newline to Unix newline in bash script?](http://stackoverflow.com/q/2613800/4279) – jfs Dec 16 '13 at 01:14
  • @J.F.Sebastian There is a difference between removing bytes and replacing, I would like to replace, not delete. And it is impossible to install non-standard utilities. Only sed, bash, tr is available... – Epsiloncool Dec 16 '13 at 01:38
  • 1
    I don't understand your comment e.g., in what way `sed $'s/\r$//'` fails for you? There could be invalid for your use-case answers but the question is 100% related. – jfs Dec 16 '13 at 01:45
  • 2
    I've noticed that instead of replacing `\r\n` with `\n`, you want replace `\r\n` with `\r`. Is it correct? – jfs Dec 16 '13 at 01:58
  • @J.F.Sebastian Yes, I wrote about I need for \r, but actually I am looking for relatively universal solution for replacement bytes. I've tried everything already and didn't get any positive result. But thanks, your comment would be best answer. – Epsiloncool Dec 16 '13 at 06:11

2 Answers2

0

Yes. The name of the tools are:

fromdos

todos

They are in the package tofrodos in most distributions.

peterh
  • 11,875
  • 18
  • 85
  • 108
0

You can use the command dos2unix. The inverse is unix2dos, of course.

rodrigo
  • 94,151
  • 12
  • 143
  • 190