Incomputing, acommand is a high-level instruction received via an externalinterface that directs the behavior of acomputer program. Commonly, commands are sent to a program via acommand-line interface, ascript, anetwork protocol, or as an event triggered in agraphical user interface.[1]
Many commands supportarguments to specify input and to modify default behavior. Terminology and syntax varies but there are notable common approaches. Typically, anoption or aflag is a name (withoutwhitespace) with a prefix such asdash orslash that modifies default behavior. An option might have a required value that follows it. Typically, flag refers to an option that does not have a following value. Aparameter is an argument that specifies input to the command and its meaning is based on its position in the command line relative to other parameters; generally ignoring options. A parameter can specify anything, but often it specifies afile byname orpath.[2]
The termcommand is sometimes also used for internal program instructions, but often other terms are more appropriate such asstatement,expression,function, orconditional.[3][4] For example, printing a message in Bash is via thecommandprintf, while in Python it is via thefunction print().[5] Further, some aspects of adjacent technology are conflated with commands. For example, conditional logic in Bash and Python is called anexpression[6][7] andstatements in Java.[8][9]
A notable context in which commands are prevalent is theoperating systemshell. Commonly, the shell dispatches a command to a program that has a file name matching the first parameter. In aUnix shell (such asbash and many related variants), the match must be exact including case.[10] The following bash command changes theworking directory to/home/pete by invoking the programcd:
cd/home/peteThe following bash command writes "Hello World" via programecho tostandard output – typically theterminal. Quotes around the two words indicate that the phrase is treated as a single parameter.
echo"Hello World"
The following demonstrates how the default behavior of a command is modified with a switch. The switch-e causes the command to treat characters prefixed with a backslash as the associated control character. In this case\t results in a tab character.
echo-e"Hello\tWorld"
In shells such ascommand prompt,DOS, andOS/2 some commands arebuilt-in: not implemented as a separate program.[11] But, if a command is not built-in, then the shell dispatches to a program that has an executable extension (such as.exe) and base name matching the first parameter ignoring case. The following command prompt command displays the content of filereadme.txt via the built-in commandtype.[12]
type readme.txtThe following command prompt command lists the contents of the current directory via built-in commanddir. The switch/Q modifies default behavior to include owner information.[13]
dir /Q