On 03/16/2017 06:33 AM, Marc Chamberlin wrote:
On 03/15/2017 09:45 PM, L A Walsh wrote:
Marc Chamberlin wrote:
darkstar:/usr/lib/systemd/system # grep run * grep: invalid option -- '.' Usage: grep [OPTION]... PATTERN [FILE]...
Try grep -- run *
Likely some file name is being taken as a grep option.
OKeyDoKey! Didn't see that one coming or in the documentation! A magic dash dash does the trick! Thanks L A Walsh for the proper incantation.
This is common to most-to-all command-line utilities using the library functions getopt(3)/getopt_long(3) to parse options ('man getopt_long'). In coreutils, this is documented in "common options": https://www.gnu.org/software/coreutils/manual/html_node/Common-options.html#... ‘--’ Delimit the option list. Later arguments, if any, are treated as operands even if they begin with ‘-’. For example, ‘sort -- -r’ reads from the file named -r. And there's also an FAQ entry: https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#How-do-I-remov... I'm wondering why this isn't mentioned in grep's documentation ... yet: you should ask to add it to the documentation on the grep mailing list (mailto:bug-grep@gnu.org) - a wonderful start to contribute to open source. ;-) Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org