Hmm - that script doesn't actually do anything, and you don't 
want to have to edit the script every time you want to convert a 
file.  A much shorter one-liner script will get the job done on 
the command line:

    perl -pi -e "tr/\r//d" <file1> <file2> <file3> ...

For this reason, I have the following in my ~/.login file:

    alias mac2unix 'perl -pi -e "tr/\r/\n/"'
    alias dos2unix 'perl -pi -e "tr/\r//d"'

  -Ken


On Friday, September 27, 2002, at 03:26  AM, Robin wrote:
> On Friday, September 27, 2002, at 01:57  am, Adriano Allora wrote:
>> I need to convert some dos files in unix files, are there 
>> commands I can use (like recode)?
>
> I'm assuming you mean text files and you need to convert line 
> endings. You'll need to edit the @files array putting in the 
> full paths to the files you want to update, saving them to disk 
> I'll leave up to you ;-)
>
> ==cut below this text=
> #!/usr/bin/perl -w
>
> use strict;
>
> # Unix systems (Unix, Linux, OSX)  '\n' = ASCII '\012' ('\f' 
> line feed).
> # MacOS9 and earlier                        '\n' = ASCII '\015' 
> ('\r' carriage return).
> # MS-DOS,Windows systems           '\n' = ASCII '\012\015' 
> ('\f\r' line feed + carriage return).
>
> my($temp,@files);
> @files=(ADD YOUR FILE LIST HERE);
>
> for $temp(@files){
>       open (IN,$temp);
>       
>       while (<IN>) {
>               tr/\015/\012/s ;        # change Dos/Win/Mac line endings 
> to Unix/OSX ones              }
> }
> ==cut above this text=
>
> HTH
>
> Robin
>

Reply via email to