[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in grep
From: |
Bob Proulx |
Subject: |
Re: bug in grep |
Date: |
Wed, 9 Mar 2005 09:25:46 -0700 |
User-agent: |
Mutt/1.5.6+20040907i |
Ian Beaumont wrote:
> In Suse Linux 9.1 I can create a file 'file' with a single entry, c.
> 'grep [b-d] file' will find the entry, while
> 'grep [a-d] file' will not.
Thank you for reporting this problem. However I do not believe this
is a program bug. Instead I think it is a problem in the usage of the
program. There are a couple of problems with the above.
The brackets are special to the shell and should be quoted to protect
them. They are called shell metacharacters and in the above context
may be expanded to match files that happen to be in the current
directory.
The character ranges such as you are using will be affected by the
current locale setting. Therefore the result may depend upon whether
the currently selected locale data places the character within that
range or not.
Try this:
locale
export LC_ALL=POSIX
local
grep "[a-d]" file
The first prints the current locale setting. Then set it to a
standard locale and show that. Finally in the standard locale run the
command. The pattern with shell metacharacters is quoted to protect
it from shell filename expansion.
Hope that helps.
Bob
- bug in grep, Ian Beaumont, 2005/03/07
- Re: bug in grep,
Bob Proulx <=