We just can’t remember options of CLI tools.
In most cases, --help
, like grep --help
, is the go-to way to look for help.
For example, if you forget what -H
of grep
does.
$ grep --help | grep -- -H
-H, --with-filename print the file name for each match
man
is too formal, wordy and overwhelming, comparing with --help
.
Usually, we can find out most of what we want in the output of --help
, without turning to man
.
In some environments, man
pages may not be available there. One such example is Git Bash for Windows.
Commands in Git Bash for Windows don’t have man pages.
Relying on man
only means you have to google the man(ual) in the browsers.
To save some typing, a bash function can also be added into the ~/.bashrc
.
h() { $1 --help; }
Then type h grep
to show the help.
Note that different commands or different variants of a command may print help text in different verbosity.
For example, the builtin grep
in OS X prints help text like below.
$ grep --help
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
It’s much less than the Linux grep
’s help text.
(Most of CLI tools support this level of help text at least.)