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

Submitter:  Mikko Mallat <mikkom>
Submitted:  Thu 30 Nov 2006 12:21:55 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-10-07 taa StatusNone Invalid
        Open/ClosedOpen Closed
    2006-11-30 mikkom Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code