[Techtalk] real life kewl text-processing and regexps sampleswanted

Telsa Gwynne hobbit at aloss.ukuu.org.uk
Sat Jan 10 14:08:13 EST 2004


On Sat, Jan 10, 2004 at 01:54:37PM +0100 or thereabouts, dominik.schramm at gmxpro.net wrote:
> "Kathryn Hogg" <kjh at flyballdogs.com> writes:
> > Brenda Bell said:
> >> A command I use a lot is:
> >>     cat dos-file.txt | sed -e '1,$s\^M\\g' >linux-file.txt
> > I use dos2unix for those conversions.
> 
> dos2unix is not always installed. When I have to 
> convert DOS to Unix line endings on such systems
> (and I don't want to/can't install dos2unix) I use 
> 
> perl -pi -e 's/\r\n/\n/' filename

There's obviously a ton of ways to do this. Some more were
recounted some years ago on techtalk: 

http://linuxchix.org/pipermail/techtalk/2000-September/thread.html#5350

Subject line: "dos to unix"

Also from my directory of handy-tricks, a file called
"replacing-lf-with-tr" (yes, I like long filenames): 

  tr -d '\015'

\015 is, according to 'man ascii', 

  Oct   Dec   Hex   Char
  015   13    0D    CR  '\r'

I have never actually tried this one I mention, so if
this actually eats files, I apologise.

Telsa



More information about the Techtalk mailing list