GNU bug report logs -
#15937
inconsistent behavior when using the -f option
Previous Next
Full log
Message #8 received at 15937 <at> debbugs.gnu.org (full text, mbox):
tags 15937 notabug
close 15937
thanks
On Wed, Nov 20, 2013 at 11:34 AM, Aaron Selk
<aaron_selk <at> generalplastics.com> wrote:
> The following command produces matches.
> # egrep ^[\[].+[\]] /var/log/apache2/error.log
>
> However, if I save the pattern to a file and use the -f option, it produces no matches.
> I have to change the pattern to this:
> ^[\[].+\]
>
> Notice I had to remove the enclosing square brackets to get the literal closing bracket to match when using the -f option.
Thanks for the report, but the only problem is that you have not
quoted the regular expression, and that makes it subject to evaluation
by your shell.
I suggest trying hard to single-quote (double-quote only when
necessary) grep regular expressions that are specified on the command
line.
This demonstrates that a properly-quoted regexp works the same on the
command line as when included as the contents of an -f-specified file:
$ echo '[x]' | grep -E '^[[].+[]]'
[x]
$ echo '[x]' | grep -E -f <(echo '^[[].+[]]')
[x]
This bug report was last modified 11 years and 134 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.