Subcommand

noun

say it: “SUB-kuh-mand” /ˈsʌbkəˌmænd/

A word after a tool's name that picks which of its jobs to do, such as commit in git commit.

What is a subcommand?

A subcommand is the word after a tool's name that picks which job it does: git commit, apt install, recipes add. Everything after it belongs to that job, so -m means something to git commit and nothing to git status. In a bash script, a case on $1 picks the job.

case "$1" in
  add) shift; cmd_add "$@" ;;
  list) shift; cmd_list "$@" ;;
  *) echo "recipes: there's no $1 command. Try: recipes --help" >&2; exit 2 ;;
esac
# ./recipes cook  prints  recipes: there's no cook command. Try: recipes --help

In a sentence

  • “Each subcommand of git has its own options: -m means something only to commit.”
  • “add is a subcommand of recipes, and list is another.”

Level: Apprentice · More Unix terms at this level

Updated