[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sun, 18 May 2008 17:25:19 -0700 (PDT)
> 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
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.
"-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:
The Single Unix Specification states that
Options without option-arguments should be accepted when grouped
behind one "-" delimiter.
-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:
Sent from the Gnu - Grep mailing list archive at Nabble.com.