CRLF / LF Conversion

William R. Knox wknox at
Tue Sep 26 18:36:10 GMT 2000

I had to write the following little PERL script for a bunch of people
who were running into CR/LF problems with Macs and Netatalk. It converts
all the files ending in .shtm, .htm, .html, and .shtml (regardless of
case) given as arguments, and recursively searches for all the files in
directories given as arguments matching the same expression, changing CR
to LF. To put it more bluntly,

./ file1.html directory2 ...

It could be easily modified to change CRLF to LF or vice versa by
changing the values of $OLD_EOL and $NEW_EOL.

Let me know if you find it useful.

			Bill Knox
			Senior Operating Systems Programmer/Analyst
			The MITRE Corporation

Peter Samuelson wrote:
> [cybrgeek at <cybrgeek at>]
> > > It is my understanding that Samba cannot do CRLF / LF Conversion
> > > when needed (from CRLF-LF-Conversions.txt).
> Correct, and for very good reasons.
> > > I am currently sharing my html directory which had be edited via
> > > pico.  Assuming that all my html files are either .html or .htm,
> > > what would be the best way to convert them to the windows end
> > > lines?
> > Look into the dos2unix and unix2dos programs. They do the CR/LF<->NL
> > translations very well.
> Note also that if you don't have the utilities handy, use
>   unix2dos-in-place == perl -pi -e 's/$/\015/' filename(s)
>   dos2unix-in-place == perl -pi -e 's/\015$//' filename(s)
> or similar with tr, sed, mv, rm and redirecting.
> Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Type: application/x-perl
Size: 2322 bytes
Desc: not available
Url :

More information about the samba mailing list