[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15937: inconsistent behavior when using the -f option

From: Jim Meyering
Subject: bug#15937: inconsistent behavior when using the -f option
Date: Wed, 20 Nov 2013 16:53:48 -0800

tags 15937 notabug
close 15937

On Wed, Nov 20, 2013 at 11:34 AM, Aaron Selk
<address@hidden> 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
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 '^[[].+[]]'
$ echo '[x]' | grep -E -f <(echo '^[[].+[]]')

reply via email to

[Prev in Thread] Current Thread [Next in Thread]