Jump to content

Command (computing)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 15.195.185.82 (talk) at 09:00, 13 December 2013 (Examples). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computing, a command is a directive to a computer program acting as an interpreter of some kind, in order to perform a specific task. Most commonly a command is a directive to some kind of command-line interface, such as a shell.

Specifically, the term command is used in imperative computer languages. These languages are called this, because statements in these languages are usually written in a manner similar to the imperative mood used in many natural languages. If one views a statement in an imperative language as being like a sentence in a natural language, then a command is generally like a verb in such a language.

Many programs allow specially formatted arguments, known as flags or options, which modify the default behaviour of the command, while further arguments describe what the command acts on. Comparing to a natural language: the flags are adverbs, whilst the other arguments are objects.

Examples

Here are some commands given to a command-line interpreter (Unix shell).

The following command changes the user's place in the directory tree from their current position to the directory /home/pete. cd is the command and /home/pete is the argument:

 cd /home/pete

The following command prints the text Hello World out to the standard output stream, which, in this case, will just print the text out on the screen. echo is the command and "Hello World" is the argument. The quotes are used to prevent Hello and World being treated as separate arguments:

 echo "Hello World"

The following commands are equivalent. They list files in the directory /bin. ls is the command, /bin is the argument and there are three flags: -l, -t and -r:

 ls -l -t -r  /lvl 100
 ls -ltr  /bin

The following command displays the contents of the files ch1.txt and ch2.txt. cat is the command and ch1.txt and ch2.txt are both arguments.

 cat ch1.txt ch2.txt

The following command lists all the contents of the current directory. dir is the command and "A" is a flag. There is no argument. Here are some commands given to a different command-line interpreter (the DOS, OS/2 and Microsoft Windows command prompt). Notice that the flags are identified differently but that the concepts are the same:

 dir /A

The following command displays the contents of the file readme.txt. type is the command. "readme.txt" is the argument. "P" is a parameter...

 type /P readme.txt

See also