On Fri, May 28, 2010 at 3:06 AM, Paul Boniol <[email protected]> wrote:
> Another programmer uses a Mac, and occasionally some program reverts to
> using the old line terminator (carriage return only).  So we end up with an
> occasional CR only file mixed in with lots of other "normal" files.  The DOS
> and Linux files work fairly well without any issues, but the CR only files
> reek havoc when I grep under Linux (returning the entire file).
> I know how to find text files under Linux (i.e. non-binary), but is there an
> easy way to find old style Mac text files only, so I can convert them?

You're looking for CR that's followed by something other than NL.  I
don't think you can use grep to find them, but a perl script would
work.  You can also fix them pretty easily in perl:

perl -n -e 'chomp; s/\r(?!\n)/\n/g; print;'

Do something like this:

perl -p -i -e 'chomp; s/\r(?!\n)/\n/g; print;' files-to-fix

To fix them in-place.

Michael
-- 
Michael Darrin Chaney, Sr.
[email protected]
http://www.michaelchaney.com/

-- 
You received this message because you are subscribed to the Google Groups 
"NLUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nlug-talk?hl=en

Reply via email to