Darn, ntubski got to the explanation before I did.
Indeed, with almost any command, arguments that begin with leading hyphens will confuse them. Most of the common ones will recognize the special '--
' option that signals the end of command options. See "info coreutils > Common Options
also have '-e
', which can be used to explicitly specify that the following token is a pattern expression. '-e
' also allows you to give multiple expressions at once.
As for grep
's recursion option, since it operates on directories you shouldn't use a generic globbing pattern like '*
'. Instead just give it one or more starting directories to search from. In practice this usually means using '.
' as the argument, unless you want it to start at a different place.
You can also specify --include=
globbing options to filter what it processes. Note that these globs are handled by grep
, not the shell, and so need to be quoted so that they get passed to it unexpanded.