Re: DOS newlines (CR/LF) to Unix format [message #171735 is a reply to message #171731] |
Wed, 19 January 2011 12:47 |
Michael Fesser
Messages: 215 Registered: September 2010
Karma:
|
Senior Member |
|
|
.oO(Bjarne Jensen)
> I found this snippet on internet:
>
> # IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
> awk '{sub(/\r$/,"");print}' # assumes EACH line ends with Ctrl-M
>
> It works fine on the commandline so I wrote like this in a php-script:
>
> - - -
>
> $unix = ".unix";
>
> foreach (glob($usedir."[12_]*") as $filename) {
> exec('awk { sub("/\r$", ""); print } $filename > $filename.$unix');
> }
>
> - - -
>
>
> But absolutely nothing happens!
>
> Why not?
Besides the other replies - may I ask why you need this? I consider line
ending conversion a relic from the 1980s. Today only very few and very
old and very badly written software should have a problem with different
line endings.
Micha
|
|
|