Command line parameters under CENTOS

written in front

- and - - : represent one horizontal line (one dash) and two horizontal lines (two dashes) respectively. Due to the reason displayed by the editor, spaces can only be added for distinction.

overview

In LINUX SHELL, we call - or - - plus a character (string) as a command line parameter.
When designing command-line programs in UNIX, it is necessary to distinguish the "Options" (Options) and "Arguments" (Arguments) of a command, so "-" is introduced. Anything starting with "-" is an option, and the option is marked with a single letter, which is usually the first letter of an option English word. For example, "-a" means all (all), "-c" means command (command), "-f" means file (file), "-V" means version (version), and multiple options can also be written consecutively, such as "ls -A -l" can be written as "ls -Al".
However, the number of individual letters would be insufficient and the meaning expressed would not be clear enough. So there is a later GNU style to improve the above shortcomings, using "- -" as a prefix, followed by a string of words, such as "- -version", "- -all". The parameters of the option can be separated by spaces at the back, and "=" can be used, such as "- -file atlas.log" is equivalent to "- -file=atlas.log".
This GNU-style option is often called "Long Options" (Long Options), while the Unix-style is "Short Options" (Short Options). Generally speaking, short options have corresponding long options, such as " -a, - -all", "-V, - -version".

the term

(1) Short option: It means a short parameter, usually consisting of a hyphen and a letter (uppercase or lowercase), such as: -a, -v, etc.
(2) Long option: It means a longer parameter, usually a word composed of two hyphens and some letters, such as: - -help, - -version, - -size, etc.
Note:
The above is usually the case. Of course, there are some commands that do not follow the above rules of short options and long options, such as: find . -name "*.java" or java -version

The difference between - and - -

-sh : Indicates a combination of s and h options
- -sh : Indicates that sh is a single option

style

name illustrate
UNIX / POSIX style parameters Add a single dash in front of the parameter
BSD style parameters No dashes in front of parameters
GNU style parameters Add a double dash in front of the parameter

(1) UNIX / POSIX style parameters: a minus sign followed by a letter (multiple letters), a letter is a parameter, two letters are two parameters, such as:

jps -l
ls -l
rm -fr /
# git -am 其实是 -a -m 两个参数,可以分开写,也可以合起来写。
git commit -am "xxx" 

(2) BSD style parameter: This parameter is very similar to the first one, that is, without a minus sign, such as:

ps ef
tar cjvf atlas.tar.bz2 .

In the above example, ef is two parameters; cjvf is four parameters (the UNIX style can also be used, with a single minus sign in front).

(3) GNU style parameters: two minus signs with a word (phrase), a word (phrase) means a parameter, such as:

npm install lodash --save
tsc --init
ps --no-headers

Guess you like

Origin blog.csdn.net/goodjava2007/article/details/131083116