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

Re: HELP: w/ grep on a log file.



On Sat, 13 Jun 1998, Johann Spies wrote:

> Hallo, 
> 
> Sorry if this bores you, but I have never used sed before and after
> reading this discussion I checked the man page for sed.
> 
> What I would like to know is the following:
> 
> On Fri, 12 Jun 1998, Steve Mayer wrote:
> 
> >   Try grep "`date \"+ %a %b %d\" | sed 's/ //'`" arch.log
>               ^                                 ^
> > dave oswald wrote:
> 
> > > grep echo  \"`date "+ %a %b %d" | sed 's/ //'`\" arch.log
>                  ^                               ^  
> What is the meaning of the ` before date and after //'?
> What was wrong with dave oswald's effort? 

My understanding is that commands between the (`)'s pass their output as
the parameter.

Try   echo `hostname`   or suchlike

> Why wouldn't 
> 
> grep \"`date "+ %a %b %d" | sed 's/ //'`\" arch.log
> 
> work?

grep expects one string for its pattern input. enclosing it in quotes (")
makes it one string. using \" is an escape to tell grep to look for a " in
the file, but just " bounds the pattern to search for.

i.e.

grep "hello world" file
looks for the string  'hello world' in the file 'file' wheras:

grep \"hello world\" file
looks for the string  '"hello' in the files 'world"' and 'file' and:

grep "\"hello world\"" file
looks for the string '"hello world"' in the file 'file'.

Hope that helps.

For all the grep gurus out there, correct me if I am wrong.. PLEASE!

                       Michael Beattie (mickyb@es.co.nz)

-------------------------------------------------------------------------------
                 Documentation - The worst part of programming.
-------------------------------------------------------------------------------
                Debian GNU/Linux....  Ooohh You are missing out!


--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: