Re: DOS newlines (CR/LF) to Unix format [message #171732 is a reply to message #171731] |
Wed, 19 January 2011 11:25 |
Luuk
Messages: 329 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 19-01-11 11:59, Bjarne Jensen wrote:
> 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');
the single quotes around your AWK-script are missing...
> }
>
> - - -
>
>
> But absolutely nothing happens!
there might be an error on your log..
>
> Why not?
>
>
> /Bjarne
you also could try 'dos2unix'
see: man dos2unix
or: http://linux.die.net/man/1/dos2unix
--
Luuk
|
|
|