linux命令什么时候加与不加横杠?

来源:百度知道 编辑:UC知道 时间:2024/06/26 05:29:44
比如 tar xvfz filename.tar.gz
就不加横杠 -
但是其他的
又要加 比如 find / -name "filename"
name前加了-

命令有参数的时候空一格加一个 “-”
例如: ll -Z
shell写判断的时候的判断参数需要有“-”
例如:if [ -d /var ]; then echo "/var is a directory"; else echo "/var is not exists"; fi;

-name 是固定写法。-time,-size 什么的。必须写的这是。

以 man ps 为例
This version of ps accepts several kinds of options:

1 UNIX options, which may be grouped and must be preceded by a dash.
2 BSD options, which may be grouped and must not be used with a dash.
3 GNU long options, which are preceded by two dashes.

以man tar为例
The first argument to tar should be a function; either one of the letters
Acdrtux, or one of the long function names. A function letter need not
be prefixed with ``-'', and may be combined with other single-letter
options. A long function name must be prefixed with --. Some options
take a parameter; with the single-letter form these must be given as sep‐
arate argument