Command Line Option

Why Trust Techopedia

What Does Command Line Option Mean?

Command-line options are commands used to pass parameters to a program. These entries, also called command-line switches, can pass along cues for changing various settings or executing commands in an interface.


Techopedia Explains Command Line Option

The syntax of command-line options differs from one operating system to another. In MS-DOS/Windows, by convention, a command-line option is indicated by a letter prefixed with a forward slash.

As an example, the XCOPY command, which is used for copying files and directories, can be started using the the following options, among others:

  • /T — copy the directory structure only
  • /C — continue even if an error occurs
  • /R — overwrite read-only files

Thus the command “xcopy c:dir1 d:dir2 /R” will copy files and subdirectories from the subdirectory “dir1” in drive “C:” to the subdirectory “dir2” in drive “D:”, overwriting read-only files already present in “d:dir2”.

In Unix, the convention is to use a hyphen instead of a forward slash, followed by a letter. For example, the command “ls -l” will perform a long listing (“-l”) of the files and subdirectories in the current directory. The list will include other information such as the file sizes, attributes, modification dates, etc. Without the “-l” option, only the names of the files and subdirectories will be listed.

The choice of using a forward slash or a hyphen is programmer dependent. For example, most Linux programs that have been ported to Windows still use the Unix convention when indicating command-line options. The source code must be modified to use the Windows convention.


Related Terms

Margaret Rouse
Technology Expert
Margaret Rouse
Technology Expert

Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages.