LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-20-2011, 01:26 AM   #16
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,505

Rep: Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890

Well ... I am now officially confused :$

I have replicated David's tree from last post and executed all commands in the same order and my CLFS based system is getting different results
In fact, they are the expected results that the OP was looking for, I believe???
Code:
$ grep -rli 'foo' *
foofile-lvl1.sh
foofile-lvl1.txt
lvl2/foofile-lvl2.sh
lvl2/lvl3/foofile-lvl3.sh
lvl2/lvl3/foofile-lvl3.txt
lvl2/foofile-lvl2.txt
lvl2a/foofile-lvl2a.sh
lvl2a/lvl3a/foofile-lvl3a.sh
lvl2a/lvl3a/foofile-lvl3a.txt
lvl2a/foofile-lvl2a.txt

$ grep -rli 'foo' .
./foofile-lvl1.sh
./lvl2/foofile-lvl2.sh
./lvl2/lvl3/foofile-lvl3.sh
./lvl2/lvl3/foofile-lvl3.txt
./lvl2/foofile-lvl2.txt
./foofile-lvl1.txt
./lvl2a/foofile-lvl2a.sh
./lvl2a/lvl3a/foofile-lvl3a.sh
./lvl2a/lvl3a/foofile-lvl3a.txt
./lvl2a/foofile-lvl2a.txt

$ grep -rli --include='*.txt' 'foo' *
foofile-lvl1.txt
lvl2/lvl3/foofile-lvl3.txt
lvl2/foofile-lvl2.txt
lvl2a/lvl3a/foofile-lvl3a.txt
lvl2a/foofile-lvl2a.txt

$ grep -rli --include='*.txt' 'foo' .
./lvl2/lvl3/foofile-lvl3.txt
./lvl2/foofile-lvl2.txt
./foofile-lvl1.txt
./lvl2a/lvl3a/foofile-lvl3a.txt
./lvl2a/foofile-lvl2a.txt

$ grep -rli --include='*.txt' 'foo' . ./lvl2/lvl3/foofile-lvl3.sh
./lvl2/lvl3/foofile-lvl3.txt
./lvl2/foofile-lvl2.txt
./foofile-lvl1.txt
./lvl2a/lvl3a/foofile-lvl3a.txt
./lvl2a/foofile-lvl2a.txt
So apart from different sorting, I seem to only be getting txt files when using --include
and I am not getting any exclusions???
 
Old 04-20-2011, 01:48 PM   #17
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959
Found it. The include=exclude thing's a bug. And it's been fixed, at least in any distro that's up-to-date. Which of course doesn't include Debian, which is still using version 2.6.3.

http://savannah.gnu.org/bugs/index.php?29876

I wonder if that's what's affecting the processing order too?

Last edited by David the H.; 04-20-2011 at 01:49 PM.
 
Old 04-20-2011, 01:50 PM   #18
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,019

Original Poster
Rep: Reputation: 67
You guys are hard-core!

I agree that exclusion of files that match your --include filter in the top-level directory is totally, completely bizarre. I assert once again this is NOT how grep behaves on other machines. I just performed this command on a CentOS 5 machine and the results included numerous php files in the top-level directory:
Code:
grep --include=*.php -irl 'adams' *
I can deal with typing a period instead of a wildcard every time, what's worrisome to me is that Ubuntu 10 is behaving differently than CentOS 5 (and various debian distros as well AFAIK).
 
Old 04-20-2011, 01:51 PM   #19
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,019

Original Poster
Rep: Reputation: 67
Quote:
Originally Posted by David the H. View Post
Found it. The include=exclude thing's a bug. And it's been fixed, at least in any distro that's up-to-date. Which of course doesn't include Debian, which is still using version 2.6.3.
Nice work. Do you have to upgrade linux kernel to fix the bug or it some other library?
 
Old 04-20-2011, 02:07 PM   #20
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959
It's a bug in grep, so you simply need to upgrade grep.

2.6.3, and perhaps other 2.6 releases, show the problem. The newest version, 2.7, as well as 2.5.4 and before appear to be ok, according to the bug report.

If you can survive it, just wait for your distribution to do it. They'll get around to upgrading the package eventually. If you really need this feature right away, you'll have to download the source from gnu and compile it yourself.

ftp://ftp.gnu.org/gnu/grep/
 
Old 04-20-2011, 07:42 PM   #21
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,505

Rep: Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890
Thanks David ... that would explain it as my CLFS system is fairly bleeding edge
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to force sudo to use ~/.bashrc aliases? bigrigdriver Linux - General 10 02-24-2008 05:14 PM
Eterm doesn't import aliases from bashrc oldmanofthesea Linux - General 1 05-16-2005 07:17 AM
bashrc Aliases don't work soren625 Linux - Newbie 10 01-27-2005 08:59 AM
aliases in .bashrc file davalos Linux - Newbie 7 08-21-2003 01:03 PM
.bashrc aliases Crashed_Again Linux - General 8 01-30-2003 06:42 PM


All times are GMT -5. The time now is 03:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration