in reply to newlines for windows from unix

On a related note - how can I strip out Windows newlines from the WordPad-compiled files I now1 intend using in Linux?

Thanks!

Tiefling

1: In other words, they already exist. If I were writing them now, I'd write them in a Linux text editor.

Replies are listed 'Best First'.
Re:{2} newlines for windows from unix
by jeroenes (Priest) on Jun 07, 2001 at 18:25 UTC
    I have a script, chmod +x, in ~/bin:
    #!/usr/bin/perl -i -p tr/\015//d;
    and I run it like: removecarr.pl ugly_whoze_file Jeroen
    "We are not alone"(FZ)
Re: Re: newlines for windows from unix
by murphya (Sexton) on Jun 07, 2001 at 18:16 UTC
    May I suggest that you use a proper text editor in windows. That way your text files are not stored with the windows new line rubbish on the end.

    I use conText which I downloaded for free from the internet and which I can highly recommend (nothing can be too bad if it is free, but this is truely good ;)).

    As to your question. I have a script loops through each line of files doing a sub for 012 and 015, replacing them with nothing. In that way you remove any newlines present. Then add an 'if' keying on $^0 eg if($^0 eq 'wnt'){..... to check the OS and add the suitable newline.

    This is clunky but simple to write and quaranteed to work.

    Hope that this helps.

    "The significant problems we face in life can not be solved at the same level of thinking we were at when we created them." -Albert Einstein

Re: Re: newlines for windows from unix
by ZZamboni (Curate) on Jun 07, 2001 at 19:20 UTC