> From: Ignacio Rodriguez <[EMAIL PROTECTED]>
> 
> 
> Dave Reed wrote:
> 
> > > Do you know where I could find the source code of dos2unix and unix2dos? Just
> > > to know how they work and what they can and cannot do. Thank you.
> >
> > They're probably Perl or some other script language so you can just
> > use can look at them.
> >
> 
> No, they are ELF compiled (probably) from C. I wanted to know the source code for
> the following reason: these programs work well when the original file fulfills
> these requirements, but, for example, if you download a text file from a unix
> server with a DOS client, and separation between lines in the original file are
> \c\n these may become \c\c\n


I dug up the two Perl scripts I got quite a while ago from somewhere -
probably this list.  If they don't do exactly what you want, they're
easy to modify.

#!/usr/bin/perl -pi
#
# Convert DOS text file to Unix file format.  Conversion is done in-place.
#
# Usage: dos2unix dosfile ...
print STDERR "Converting \"$ARGV\" ...\n" if (eof || ($. == 0));
s/\015$//;                   # strip ^M from end of line.
s/\032$//;                   # strip ^Z if we see it (which'll be at EOF).


#!/usr/bin/perl -pi
#
# Convert Unix text file to DOS file format.  Conversion is done
in-place.
#
# Usage: unix2dos unixfile ...
print STDERR "Converting \"$ARGV\" ...\n" if (eof || ($. == 0));
s/$/\015/;                   # tack on ^M
s//\032/ if (eof);       # DOS ^Z at end of file.


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to