[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Script polluted by DOS formatting



On 13/07/07, Jordi Gutiérrez Hermoso <jordigh@gmail.com> wrote:
On 13/07/07, Christian Holm Christensen <cholm@nbi.dk> wrote:
> Why not write a small C++ program that does what you want:
>
>         #include <iostream>
>         int main()
>         {
>            while (!std::cin.eof()) {
>               char c = std::cin.get();
>               if (std::cin.fail()) break;
>               if (c == 0302 || c == 0240) continue;
>               std::cout.put(c);
>            }
>            return 0;
>         }

If it's going to be that kind of party, here's a Perlism to remove DOS newlines:

      perl -pi -e 's/\x0d\x0a/\x0a/' filewithdos

Er, I read that too quickly. Here's a similar Perlism to remove the
offending characters instead.

    perl -pi -e 's/\302|\240//' soiled-file

- Jordi G. H.



Reply to: