Content deleted Content added
→Examples: Divise Owner has full access to all permission Tags: Reverted references removed |
Reverted 1 edit by 41.13.0.220 (talk): Edit summary doesn't correspond with edit |
||
Line 11:
==Examples==
A notable context in which commands are prevalent is the [[operating system]] [[shell (computing)|shell]]. Commonly, the shell dispatches a command to a program that has a file name matching the first parameter. In a [[Unix shell]] (such as [[Bash (Unix shell)|bash]] and many related variants), the match must be exact including case. The following bash command changes the [[working directory]] to ''/home/pete'' by invoking the program ''[[Cd (command)|cd]]'':
<syntaxhighlight lang="bash">
cd /home/pete
</syntaxhighlight>
The following bash command writes "Hello World" via program [[Echo (command)|echo]] to [[standard output]] {{endash}} typically the [[computer terminal|terminal]]. Quotes around the two words indicate that the phrase is treated as a single parameter.
<syntaxhighlight lang="bash">
echo "Hello World"
</syntaxhighlight>
The following demonstrates how the default behavior of a command is modified with a switch. The switch {{code|-e}} causes the command to treat characters prefixed with a backslash as the associated control character. In this case {{code|\t}} results in a tab character.
<syntaxhighlight lang="bash">
echo -e "Hello\tWorld"
</syntaxhighlight>
In shells such as [[Cmd.exe|command prompt]], [[DOS]], and [[OS/2]] some commands are built-in; are not implemented as a separate program. 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 file ''readme.txt'' via the built-in command ''[[TYPE (DOS command)|type]]''.<ref>{{cite web | url = https://ss64.com/nt/type.html | access-date = 14 March 2019 | title = Type - Display a text file - Windows CMD | publisher = SS64.com }}</ref>
<syntaxhighlight lang="batch">
type readme.txt
</syntaxhighlight>
The following command prompt command lists the contents of the current directory via built-in command ''[[Dir (command)|dir]]''. The switch ''/Q'' modifies default behavior to include owner information.<ref>{{cite web | url = https://ss64.com/nt/dir.html | access-date = 14 March 2019 | title = DIR - list files and folders - Windows CMD | publisher = SS64.com }}</ref>
<syntaxhighlight lang="batch">
dir /Q
</syntaxhighlight>
== See also ==
|