in reply to Re: One Liner to strip crlf
in thread One Liner to strip crlf

Hi, To clarify. I'm trying to create a one-liner that looks at the first line only to see if it has a CRLF, and if it does, then go ahead and execute the search and replace on all lines. The search and replace command works. The piece i can't figure out is how to check if a condition exists on the 1st line only and if it does...then execute the command on the entire file in a one-liner.

Replies are listed 'Best First'.
Re^3: One Liner to strip crlf
by Tux (Canon) on Sep 04, 2014 at 16:09 UTC

    Something like this?

    perl -pi -0e'm/\A[^\n]*\r\n/ and s/\r\n/\n/g' file

    Enjoy, Have FUN! H.Merijn