[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep

From: Bob Proulx
Subject: Re: grep
Date: Fri, 26 May 2006 22:28:16 -0600
User-agent: Mutt/1.5.9i

rme wrote:
> I just found out that grep is not working as desired
> if the line breaks in the target file are <CR> only,
> i.e. abc...xyz\o15ABC...  (no <LF>, oct 12).

I believe those are Mac style files.  You would need to convert the
file format from Mac style to Unix style.

> I have downloaded such files from the internet; they look
> o.k. when displayed in a browser or a console.

That depends.  On a Mac they should look fine, of course.  But on my
system without newlines all of the output would be seen all on one

> But grep does not take <CR> as a new line break;

That depends upon the system it is running on.  On a GNU or Unix
system lines are separated by the newline character.  Grep on a GNU
system would respect that.  Grep on a Mac system would be ported to
use the newline conventions on that platform.  Assuming that you are
running on a GNU or Unix system then what you are seeing is expected.

You will need to convert those files from CR line ending format to NL
line ending format.  The tr command can do this for you easily.  Try
this command.

  tr "\015" "\012" < inputfile > outputfile

You can even do this on the fly with grep:

  tr "\015" "\012" < inputfile | grep somepattern

Hope that helps,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]