bug-grep
[Top][All Lists]
Advanced

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

Re: Grep


From: pearls
Subject: Re: Grep
Date: Sun, 18 May 2008 17:25:19 -0700 (PDT)



pearls wrote:
> I was trying to do grep -fl <filename1> <filename2>
> it reported an error stating that:
>  
> grep: l: No such file or directory
> 
> Is it a bug or there is some logical reason behind it.

The -f option takes a filename.  The grep documentation says:

       grep [options] [-e PATTERN | -f FILE] [FILE...]

       -f FILE, --file=FILE
              Obtain patterns from FILE, one per line.  The  empty  file 
con‐
              tains zero patterns, and therefore matches nothing.

Saying "-fl" is the same as "-f l" says that "l" is a file of
patterns.  If there is no such file or directory named "l" in the
current directory to satisfy that option then that is the logical
reason behind it complaining that it cannot be opened.

Bob



"-fl" works fine, because "-f" means "Look in the named file for a list
of expressions to search for"; then we have to know what the name of the
file is, and POSIX says that it follows "-f" immediately, so

  grep -fexpressions files

  grep -f expressions files

this is based on POSIX basis rather than on GNU standards which has
bundling(meaning thereby -xvf == -x -v -f)

Furthermore, the Linux Standard Base specifies that grep in this
instance works the same way as the Single UNIX Specification:

http://www.linux-foundation.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/grep.html

The Single Unix Specification states that

Guideline  5:
   Options without option-arguments should be accepted when grouped
   behind one "-" delimiter.
http://opengroup.org/onlinepubs/007908799/xbd/utilconv.html#usg

-f is *not* an option without an option-argument, and therefore can't be
"grouped", or bundled.

In other words, you will break the specifications if you change grep to
work this way: you will have a broken grep.




-- 
View this message in context: 
http://www.nabble.com/Grep-tp17304979p17309417.html
Sent from the Gnu - Grep mailing list archive at Nabble.com.





reply via email to

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