RE: [ILUG] grep problems

From: Kenn Humborg (kenn at domain bluetree.ie)
Date: Fri 27 Sep 2002 - 18:15:03 IST


> Can anyone explain the following
> (there should be no output from any of the greps below).
>
> [pixelbeat ~]$ grep --version
> grep (GNU grep) 2.5.1
> [pixelbeat ~]$ file_ids="1025:243:file1\n243:1025:file2\n243:243:file3\n"
> [pixelbeat ~]$ echo -ne $file_ids | grep -E "(0|1|1025|0):(0|1|1025|0)"
> [pixelbeat ~]$ echo -ne $file_ids | grep -E
> "(0|1|2|1025|0):(0|1|2|1025|0)"
> 1025:243:file1
> [pixelbeat ~]$ echo -ne $file_ids | grep -E
> "(0|1|2|1025|0):(0|1|2|1025|0):"
> [pixelbeat ~]$ echo -ne $file_ids | grep -E
> "(0|1|2|3|4|5|6|7|8|9|10|65534|1025|48|0):(0|1|2|3|4|5|6|7|8|9|10|
> 65534|1025|48|0)"
> 1025:243:file1
> 243:1025:file2
> 243:243:file3
> [pixelbeat ~]$ echo -ne $file_ids | grep -E
> "(0|1|2|3|4|5|6|7|8|9|10|65534|1025|48|0):(0|1|2|3|4|5|6|7|8|9|10|
> 65534|1025|48|0):"
> 243:1025:file2

They are all correct. For example the last matches the substring "3:1025:".
The second last matches "5:2", "3:1" and "3:2" respectively.

Perhaps you need a ^ at the start of the regex?

Later,
Kenn



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:19:08 GMT