command line terminology: what are these parts of a command called?
The common names for each part is as follows:
┌1┐ ┌──2───┐
git checkout master
│ └──────3──────┘
└───────4─────────┘
Command name (first word or token of command line that is not a redirection or variable assignment and after aliases have been expanded).
Token, word, or argument to the command. From man bash:
word: A sequence of characters considered as a single unit by the shell. Also known as a token.
Generally: Arguments
Command line.
The concatenation of two simple commands with a |
is a pipe sequence or pipeline:
┌─1┐ ┌──────2──────┐ ┌─2─┐ ┌──2──┐ ┌──1───┐ ┌2┐┌2┐┌2┐┌────2─────┐ ┌2┐ ┌2┐
find transcripts/?.? -name '*.txt' | parallel -- sh -c 'echo $1 $2' {} {/}
│ └────────────3──────────────┘ └────────────3──────────────┘
└───────────────────────────────────4─────────────────────────────────────┘
Mind that there are redirection and variable assignments also:
┌──5──┐ ┌1┐ ┌─2─┐ ┌─2─┐ ┌───6──┐ ┌1┐ ┌─5─┐
<infile tee file1 file2 | LC_ALL=C cat >file
└─────────7───────────┘ └───────7────────┘
└─────────────────────4────────────────────┘
Where (beside the numbers from above):
- redirection.
- Variable assignment.
- Simple command.
This is not an exaustive list of all the element a command line could have. Such a list is too complex for this short answer.
@isaac's answer above seems good.
I want to extend this with some sources.
I guess the POSIX standard might in some sense be considered canonical.
Other sources might be man bash
and man proc
.
┌1┐ ┌──2───┐
git checkout master
│ └──────3──────┘
└───────4─────────┘
POSIX suggests that:
- Is the command name (rather than the command, though even this document uses command in places)
- Argument
- Arguments
- Command (though
man proc
uses the command line)
It also has terminology for many more complicated commands.
I think command is pretty ambiguous so perhaps the term command name and command line are good for clarity.j