Before the command line parameter "-" and "-" What is the difference?

In the Linux shell, we - and - a plus character (string) is called command line parameters, there are several mainstream style below

Unix style parameters, preceded by a single broken line -
the BSD style parameters, without the first broken line
GNU style parameters, preceded by a double broken line

  1. Unix-style parameters. A minus sign, then a letter is a parameter. Unix-style argument is inherited from the Bell Labs developed the original AT & T Unix system commands down. such as
ps -A
ls -l
rm -fr /
git commit -am "xxx"

So, why do some - followed by a letter, two letters with some of it? Actually very simple, a letter is a parameter, two letters are two parameters. Finally, the fact is -a -m git -am two parameters. Generally you can write separately, and together may write.

  1. GNU-style parameters. Let me talk about GNU style. This style is minus two - plus parameters, parameters are generally behind is followed by a word or phrase. such as
npm install lodash --save
npm install express --save-dev
tsc --init
ps --no-headers

Huh? Why do some double and single minus minus mix? In fact, in this mode, the minus sign is a double-back parameters, in a single minus a hyphen, this is the role of separating the two words is to bring, for aesthetics. Why not separated by a space then, the reason we all know. In fact - it is still behind a parameter. For example, no-headers, which means that does not display header, which is a parameter.

You can also be understood as - the latter word is a single minus sign - letter designation. For example, ls -a and ls --all mean the same thing. -h often correspond --help. -v (-V) corresponding to --version. But there are some non-mainstream exceptions.

  1. Finally, a brief talk about the third BSD-style parameters. Berkeley Software Distribution

(Berkeley software distribution, BSD) is the University of California at Berkeley developed a Unix version. It and AT & T

Unix systems have many different small, which also led to many years of Unix debate. To be honest, that I use a lot is not. This parameter and like the first, is not with the minus sign -. such as

ps aux
tar cjvf what.tar.bz2 .

In fact aux three parameters. cjvf four parameters (UNIX-style may also be used, with the addition of a single minus sign).

Published 36 original articles · won praise 2 · Views 1378

Guess you like

Origin blog.csdn.net/qq_38145502/article/details/104033079