[gentoo-user] Is grep broken?

2009-07-01 Thread Peter Humphrey
Hello list,

Can anyone explain this to me?

$ /bin/grep -r hmenu *html
index.html: 
master.html:
pictures.html:  

$ /bin/grep -r hmenu pages/*html
pages/community.html:   
pages/contacts.html:
pages/history.html: 
pages/music.html:   
pages/news.html:
pages/people.html:  
pages/pictures.html:

Grep is clearly disobeying the recursion command. I started noticing this a 
few days ago, and it's making maintenance of this directory hard work.

-- 
Rgds
Peter



Re: [gentoo-user] Is grep broken?

2009-07-01 Thread Alan McKinnon
On Wednesday 01 July 2009 16:30:26 Peter Humphrey wrote:
> Hello list,
>
> Can anyone explain this to me?
>
> $ /bin/grep -r hmenu *html
> index.html: 
> master.html:
> pictures.html:  
>
> $ /bin/grep -r hmenu pages/*html
> pages/community.html:   
> pages/contacts.html:
> pages/history.html: 
> pages/music.html:   
> pages/news.html:
> pages/people.html:  
> pages/pictures.html:
>
> Grep is clearly disobeying the recursion command. I started noticing this a
> few days ago, and it's making maintenance of this directory hard work.

You equally clearly do not understand how recursion works. You told it to grep 
through all the html files starting from pages/ and it did so.

You did not tell it to start from pages/.. so why do you think it should do 
so?

-- 
alan dot mckinnon at gmail dot com



Re: [gentoo-user] Is grep broken?

2009-07-01 Thread Patrick Holthaus
On Wednesday 01 July 2009 16:30:26 Peter Humphrey wrote:
> Hello list,
>
> Can anyone explain this to me?
>
> $ /bin/grep -r hmenu *html
> index.html: 
> master.html:
> pictures.html:  

The star is evaluated /before/ grep is executed. Therefore, only files that are 
ending with html are searched recursively. If you had placed the files in a 
directory called blablahtml, then grep would have searched there.

> $ /bin/grep -r hmenu pages/*html
> pages/community.html:   
> pages/contacts.html:
> pages/history.html: 
> pages/music.html:   
> pages/news.html:
> pages/people.html:  
> pages/pictures.html:
>
> Grep is clearly disobeying the recursion command. I started noticing this a
> few days ago, and it's making maintenance of this directory hard work.

No, you just did not tell it to search in the the directory pages. :)

HTH
Patrick



signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-user] Is grep broken?

2009-07-01 Thread Peter Humphrey
On Wednesday 01 July 2009 15:37:15 Patrick Holthaus wrote:

> No, you just did not tell it to search in the the directory pages. :)

I'm sure it used to work the way I want it to. I think I see insanity 
looming...

-- 
Rgds
Peter



Re: [gentoo-user] Is grep broken?

2009-07-01 Thread Neil Bothwick
On Wed, 1 Jul 2009 15:47:52 +0100, Peter Humphrey wrote:

> > No, you just did not tell it to search in the the directory
> > pages. :)  
> 
> I'm sure it used to work the way I want it to. I think I see insanity 
> looming...

It does work the way you want it to, just not the way you told it to :)


-- 
Neil Bothwick

Multitasking: Reading in the bathroom.


signature.asc
Description: PGP signature


Re: [gentoo-user] Is grep broken?

2009-07-01 Thread Keith Dart
On Wed, 1 Jul 2009 15:47:52 +0100
Peter Humphrey  wrote:

> I'm sure it used to work the way I want it to. I think I see insanity 
> looming...

On a side note, you might also want to investigate "sgrep", since
you're grepping inside html files.



-- 
-- 
Keith Dart

===



Re: [gentoo-user] Is grep broken?

2009-07-01 Thread Peter Humphrey
On Wednesday 01 July 2009 19:03:34 Keith Dart wrote:
> On Wed, 1 Jul 2009 15:47:52 +0100
>
> Peter Humphrey  wrote:
> > I'm sure it used to work the way I want it to. I think I see insanity
> > looming...
>
> On a side note, you might also want to investigate "sgrep", since
> you're grepping inside html files.

Thanks for the hint. I'm installing it now. Man grep didn't mention it in 
the "see also" section. Apropos didn't mention it either, since it wasn't 
installed at the time  :-(

-- 
Rgds
Peter



Re: [gentoo-user] Is grep broken?

2009-07-02 Thread Carlos

Peter Humphrey a écrit :

Hello list,

Can anyone explain this to me?

$ /bin/grep -r hmenu *html
index.html: 
master.html:
pictures.html:  

$ /bin/grep -r hmenu pages/*html
pages/community.html:   
pages/contacts.html:
pages/history.html: 
pages/music.html:   
pages/news.html:
pages/people.html:  
pages/pictures.html:

Grep is clearly disobeying the recursion command. I started noticing this a 
few days ago, and it's making maintenance of this directory hard work.




As other have pointed out, the behaviour of grep is correct in the 
examples above.


You could use the --include directive :

grep -r --include=*html hmenu .

Basically, this tells grep to recursive look for hmenu in any files that 
include *html starting from the current directory (* would be equally 
fine if you didn't want to search in 'hidden' dot directories).


Regards,
Carlos



Re: [gentoo-user] Is grep broken?

2009-07-02 Thread Peter Humphrey
On Thursday 02 July 2009 08:23:19 Carlos wrote:

> You could use the --include directive :
>
> grep -r --include=*html hmenu .

Nice idea - thanks.

-- 
Rgds
Peter