Joe B
Joe B

Reputation: 1022

How can you print all the possible commands of a unix command line tool?

I want to see a list of all possible options for a specific command line tool. The --help option can be useful, but might not include all the options and sometimes you just need a list instead of a detailed description. Basically the bash equivalent of dir() in python.

For example:

The command python --help pulls up a description of options/arguments. However it doesn't include options such as python --version. Does bash have a way to check this?

Upvotes: 0

Views: 506

Answers (1)

Dunes
Dunes

Reputation: 40753

It depends on what you're trying to get help on.

For an executable like python your best bet is the man page. This is only really available on Unix though. eg.

man python

This brings up a screen that looks like:

PYTHON(1)                   General Commands Manual                  PYTHON(1)

NAME
       python  - an interpreted, interactive, object-oriented programming lan‐
       guage

SYNOPSIS
       python [ -B ] [ -d ] [ -E ] [ -h ] [ -i ] [ -m module-name ]
              [ -O ] [ -OO ] [ -R ] [ -Q argument ] [ -s ] [ -S ] [ -t ] [ -u ]
              [ -v ] [ -V ] [ -W argument ] [ -x ] [ -3 ] [ -?  ]
              [ -c command | script | - ] [ arguments ]

DESCRIPTION
       Python is an interpreted, interactive, object-oriented programming lan‐
       guage that ...

COMMAND LINE OPTIONS
       ...

       -V ,  --version
              Prints the Python version number of the executable and exits.
       ...

This uses a program called less to display the information. You can scroll with the arrow keys and quit with q. There are more commands available in less. Type man less to find out more.

If you're looking for help on a bash builtin (eg. echo) try the bash builtin help eg.

help echo

Upvotes: 2

Related Questions