Opentopia Directory Encyclopedia Tools

Switch (command line)

Encyclopedia : S : SW : SWI : Switch (command line)


In computer software, specifically command line interfaces, a switch (also known as option, command-line parameter, or command-line argument) is an indication by a user that a computer program should change its default behaviour.

For example, in the OpenVMS operating system, the command directory is used to list the files inside a directory. By default—that is, when the user simply types directory—it will list only the names of the files. By adding the switch /owner (to form the command directory/owner), the user can instruct the directory command to also display the ownership of the files.

The format of switches varies widely between operating systems. Under the OpenVMS operating system, switches are entered in the form command/switch_1/switch_2/switch_3=value etc. The form /switch=value is used to provide an argument to the switch; for example, /user=john might specify that only files owned by the user "john" should be displayed.

MS-DOS and related operating systems typically use single-letter switches, for example dir/w/p/a:s. In this case, the : character serves the same purpose as = above.

Traditionally, the Unix operating system is similar to MS-DOS; switches are single letters, and introduced via a - (hyphen); e.g. ls -l -F -a. Multiple switches may be combined into one; so the previous command could be rewritten ls -lFa. However, with the increasingly widespread use of software from the GNU project, particularly in the Linux operating system, GNU's "long options" are also widely used. Long options are introduced via --, and are typically whole words; for example, ls --long --classify --all. Arguments to long options are provided with =, as ls --block-size=1024.

GNU -- is also used to terminate option list. This is very practical; for example, if one has file called -file1, and wants delete it by typing rm -file1, rm might think that -file1 is command line switch, and produce an error. Using rm -- -file1 reduces ambiguity.

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: