What is Command Line, Command Line Options, Command Line Arguments
Command Line
The command line was a necessary application for early computer operating systems, and was mainly responsible for the interaction between the computer and the user. When the user enters certain text commands, the command line will parse these commands and complete the related tasks, such as displaying the contents of the current directory.
Why is the command line still in use?
Although, the use of graphical interfaces has become very common, the command line still has advantages when it comes to managing computers, especially when faced with repetitive and tedious tasks, one can write multiple commands with certain logic into a script file to facilitate the execution of the task.
Command Line Commands
Command line commands are used to determine what task needs to be performed, usually it is the filename of some executable file, or what the executable file accepts, which are also known as subcommands.
In Windows Command Prompt, we try to query the registry key HKEY_CURRENT_USER\Software
using reg query
, where reg
is the command and query
is the subcommand.
reg query HKCU\Software
Command Line Options
After identifying the tasks to be performed, the user can provide a number of options to set the manner and behavior of task execution. Options generally have a uniform prefix for the same command-line application, e.g., /
in Command Prompt.
In the Command Prompt, the following command will view the files and folders contained in the current directory, with the option /w
for wide format, and the option /q
to pause when the screen is full.
dir /w /p
Command Line Arguments
In addition to command-line options, you can pass arguments to the command line, which will be used to specify execution targets or to make more subtle functional adjustments. In different command-line applications, arguments may need to be given arguments names and values, or just values.
Argument names generally have a uniform prefix, e.g., -
in PowerShell.
Here, we query the files with extension txt
in the current directory by the command Get-ChildItem
in PowerShell with the argument -Filter
denoting the filtering condition, whose corresponding value is *.txt
.
Get-ChildItem -Filter *.txt
The difference between command-line options and command-line arguments
In fact, there is no uniform standard for determining the difference between command-line options and command-line arguments; sometimes they are just called different things. Here, you can understand arguments as options with values, or as values that are directly specific to the command itself.
Case Sensitivity in the Command Line
Whether a command line is case-sensitive or not depends mainly on the operating system. Generally speaking, command lines in Windows are generally case-insensitive, while command lines in UNIX/Linux are case-sensitive. As for macOS, which is derived from UNIX, its file system is case-insensitive by default for the convenience of the average user’s daily use; after all, macOS is not designed as a server system.