buggrep - Bugs: bug #18421, grep does'nt search pattern from...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #18421: grep does'nt search pattern from first file of * set

Submitted by:  Mikko Mallat <mikkom>
Submitted on:  Thu 30 Nov 2006 12:21:55 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: Closed

Fri 01 Dec 2006 11:20:18 AM UTC, comment #2:

case closed :)

re-read the man page and so it says... my mistake, sorry!

Anyway thanks for the quick reply.

(I think I should cut down the daily coffee amount a bit..)
-Mikko

Mikko Mallat <mikkom>
Thu 30 Nov 2006 04:31:01 PM UTC, comment #1:

Mikko Mallat wrote:

> grep doesn't search pattern from first file of * set
> [snip]
> [root@Server greptest]# echo string1 > file1
> [root@Server greptest]# echo string2 > file2
> [root@Server greptest]# echo string3 > file3
> [root@Server greptest]# grep -e "string1" -f *


This is the expected result. You instructed grep to look for "string1" or the contents of 'file1' ("string1") in the files 'file2' and 'file3'. No result is the correct behavior. Re-read the man page, particularly '-f'.

> [root@Server greptest]# grep -e "string2" -f *
> file2:string2


This is correct.

> [root@Server greptest]# grep -e "string3" -f *
> file3:string3


So is this...

> [root@Server greptest]# cat file1
> string1
> [root@Server greptest]# grep -e "string1" -f *
> [root@Server greptest]# mv file1 file4
> [root@Server greptest]# grep -e "string1" -f *
> file4:string1


...and this. Now you asked grep to find "string1" and the contents of 'file2' ("string2") in 'file3' and 'file4'. Since 'file4' contains "string1", it matched the -e expression.

> [root@Server greptest]#
> [root@Server greptest]# ls -l
> total 12
> -rw-r--r-- 1 root root 8 Nov 30 13:54 file2
> -rw-r--r-- 1 root root 8 Nov 30 13:54 file3
> -rw-r--r-- 1 root root 8 Nov 30 13:54 file4
> [root@Server greptest]# grep -e "string2" -f *


And, as above, this is correct as well.

PEBKAC.

Matthew Woehlke <woehlkmp>
Thu 30 Nov 2006 12:21:55 PM UTC, original submission:

Proof of concept

Create three files in empty dir. When trying to search contents of first file, grep ignores it. When the first file is moved to the last grep finds it's content but now misses the "second" on ls -l list.

Tested on RHES 3 and SLES 9.3, according to 'info grep' both show version 2.5.1 for gnu grep.

[root@Server greptest]# echo string1 > file1
[root@Server greptest]# echo string2 > file2
[root@Server greptest]# echo string3 > file3
[root@Server greptest]# grep -e "string1" -f *
[root@Server greptest]# grep -e "string2" -f *
file2:string2
[root@Server greptest]# grep -e "string3" -f *
file3:string3
[root@Server greptest]# cat file1
string1
[root@Server greptest]# grep -e "string1" -f *
[root@Server greptest]# mv file1 file4
[root@Server greptest]# grep -e "string1" -f *
file4:string1
[root@Server greptest]#
[root@Server greptest]# ls -l
total 12
-rw-r--r-- 1 root root 8 Nov 30 13:54 file2
-rw-r--r-- 1 root root 8 Nov 30 13:54 file3
-rw-r--r-- 1 root root 8 Nov 30 13:54 file4
[root@Server greptest]# grep -e "string2" -f *
[root@Server greptest]#

rgrds,
Mikko Mallat
YIT Tietotekniikka Oy

Mikko Mallat <mikkom>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by taa (Updated the item)
  • -unavailable- added by woehlkmp (Posted a comment)
  • -unavailable- added by mikkom (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 07 Oct 2007 02:59:23 PM UTCtaaStatusNone=>Invalid
      Open/ClosedOpen=>Closed
    Thu 30 Nov 2006 12:21:55 PM UTCmikkomCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1