fbpx
Wikipedia

Command (computing)

In computing, a command is a directive to a computer program to perform a specific task. It may be issued via a command-line interface or as input to a network service as part of a network protocol, or as an event triggered in a graphical user interface.

Specifically, the term command is used in imperative programming languages. The name arises because statements in these languages are usually written in a manner similar to the imperative mood used in many natural languages. A statement in an imperative programming language would then be a sentence in a natural language, and the command would be the predicate.

Many programs allow specifically formatted arguments, known as flags or options, which modify the default behaviour of the program, while further arguments may provide objects, such as files, to act on. As an analogy to a natural language, the flags are adverbs, while the other arguments are objects.

Distinction between command and expression, statement and function edit

The meaning of command is highly dependent on context. For example, some authors refer to conditionals as commands [1] while they are called expressions in Python[2] or Bash[3] and statements in JAVA.[4] Similarly, writing to stdout is done in Bash with the builtin command printf, while it is done with the built-in function print() in Python.[5]

Examples edit

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

The following command changes the user's working position in the directory tree to the directory /home/pete. The utility program is cd and the argument is /home/pete:

cd /home/pete 

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

echo "Hello World" 

The following commands are equivalent. They list files in the directory /bin. The program is ls, having three flags (l, t, r), and the argument is the directory /bin:

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

The following command displays the contents of the files ch1.txt and ch2.txt. The program name is cat, having two file name arguments:

cat ch1.txt ch2.txt 

Here are some commands for the DOS, OS/2 and Microsoft Windows command prompt processor. The following command displays the contents of the file readme.txt. The program name is type and the argument is readme.txt.[6]

type readme.txt 

The following command lists the contents of the current directory. The program name is dir, and Q is a flag requesting that the owner of each file also be listed.[7]

dir /Q 

See also edit

References edit

  1. ^ Maurizio Gabbrielli, Simone Martini (2010). Programming Languages - Principles and Paradigms. Springer London, 6.3.2 Conditional Commands, p. 140
  2. ^ "Conditional expressions". python.org. Retrieved 23 October 2023.
  3. ^ "Bash Conditional expressions". gnu.org. Retrieved 23 October 2023.
  4. ^ "The if-then and if-then-else Statements". oracle.com. Retrieved 23 October 2023.
  5. ^ "Built-in Functions - print". python.org. Retrieved 23 October 2023.
  6. ^ "Type - Display a text file - Windows CMD". SS64.com. Retrieved 14 March 2019.
  7. ^ "DIR - list files and folders - Windows CMD". SS64.com. Retrieved 14 March 2019.

External links edit

  • command from FOLDOC
  • Windows Commands | Microsoft Docs

command, computing, system, command, redirects, here, confused, with, system, call, other, uses, command, computing, this, article, needs, additional, citations, verification, please, help, improve, this, article, adding, citations, reliable, sources, unsource. System command redirects here Not to be confused with system call For other uses see Command Computing This article needs additional citations for verification Please help improve this article by adding citations to reliable sources Unsourced material may be challenged and removed Find sources Command computing news newspapers books scholar JSTOR May 2008 Learn how and when to remove this template message In computing a command is a directive to a computer program to perform a specific task It may be issued via a command line interface or as input to a network service as part of a network protocol or as an event triggered in a graphical user interface Specifically the term command is used in imperative programming languages The name arises because statements in these languages are usually written in a manner similar to the imperative mood used in many natural languages A statement in an imperative programming language would then be a sentence in a natural language and the command would be the predicate Many programs allow specifically formatted arguments known as flags or options which modify the default behaviour of the program while further arguments may provide objects such as files to act on As an analogy to a natural language the flags are adverbs while the other arguments are objects Contents 1 Distinction between command and expression statement and function 2 Examples 3 See also 4 References 5 External linksDistinction between command and expression statement and function editThe meaning of command is highly dependent on context For example some authors refer to conditionals as commands 1 while they are called expressions in Python 2 or Bash 3 and statements in JAVA 4 Similarly writing to stdout is done in Bash with the builtin command printf while it is done with the built in function print in Python 5 Examples editHere are some commands given to a command line interpreter Unix shell The following command changes the user s working position in the directory tree to the directory home pete The utility program is cd and the argument is home pete cd home pete The following command prints the text Hello World on the standard output stream which in this case just prints the text on the screen The program name is echo and the argument is Hello World The quotes are used to prevent Hello and World being treated as separate tokens echo Hello World The following commands are equivalent They list files in the directory bin The program is ls having three flags l t r and the argument is the directory bin ls l t r bin ls ltr bin The following command displays the contents of the files ch1 txt and ch2 txt The program name is cat having two file name arguments cat ch1 txt ch2 txt Here are some commands for the DOS OS 2 and Microsoft Windows command prompt processor The following command displays the contents of the file readme txt The program name is type and the argument is readme txt 6 type readme txt The following command lists the contents of the current directory The program name is dir and Q is a flag requesting that the owner of each file also be listed 7 dir QSee also editGesture recognition List of Unix commands List of DOS commands Formal grammarReferences edit Maurizio Gabbrielli Simone Martini 2010 Programming Languages Principles and Paradigms Springer London 6 3 2 Conditional Commands p 140 Conditional expressions python org Retrieved 23 October 2023 Bash Conditional expressions gnu org Retrieved 23 October 2023 The if then and if then else Statements oracle com Retrieved 23 October 2023 Built in Functions print python org Retrieved 23 October 2023 Type Display a text file Windows CMD SS64 com Retrieved 14 March 2019 DIR list files and folders Windows CMD SS64 com Retrieved 14 March 2019 External links edit nbsp Wikibooks has a book on the topic of Guide to Windows commands command from FOLDOC Windows Commands Microsoft Docs Retrieved from https en wikipedia org w index php title Command computing amp oldid 1181506597, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.