conver dos text file to unix text file

conver dos text file to unix text file

Post by Chen » Thu, 15 Feb 2001 14:53:17



In Solaris, there is a dos2unix to do that. Is there any similar one for
FreeBSD?

Thanks

Cheng

 
 
 

conver dos text file to unix text file

Post by Douglas Coo » Thu, 15 Feb 2001 16:22:37


Create a file with the following contents, name it dos2unix, and then do
chmod u+x dos2unix.  You run it like this: dos2unix file1 file2 file3...

#!/usr/bin/perl

        print "Processing $fn";
        if(open(FILE,$fn)){
                $lc = 0;
                $file = join('',<FILE>);
                close(FILE);
                $file =~ s:\r\n|\r|\n:\n:g;
                open(FILE,">$fn");
                print FILE $file;
                close FILE;
                print "\n";
        } else {
                print " File not found!\n";
        }

Quote:}

Note that I don't claim to be a Perl guru (I made it while holding a Perl
manual open on my lap), but this has worked for me.  I can only keep so many
languages straight in my head at once...


Quote:> In Solaris, there is a dos2unix to do that. Is there any similar one for
> FreeBSD?

> Thanks

> Cheng


 
 
 

conver dos text file to unix text file

Post by Mikhail Kru » Thu, 15 Feb 2001 17:27:55


cd /usr/ports/converters/unix2dos

make; make install


> In Solaris, there is a dos2unix to do that. Is there any similar one for
> FreeBSD?

> Thanks

> Cheng

 
 
 

conver dos text file to unix text file

Post by Roman Orlo » Thu, 15 Feb 2001 23:32:31




Quote:> In Solaris, there is a dos2unix to do that. Is there any similar one for
> FreeBSD?

  tr -d "\r" ?