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

[Omaha.pm] LF -> CRLF



So we've got a bunch of Unix files that Windows can't read correctly.

   perl -pi -e 's/(?<!\r)\n$/\r\n/' /path/*

All done. Changes every file in /path/*: If the line ends in \n (LF (linefeed)) we change it to \r\n (CRLF (carriage return, line feed)).

Why not just s/\n/\r\n/ ?

Because that would change \r\n to \r\r\n. That would be bad.

Zero-width negative look behind assertions rule.

Grin,

j