在 Shell 脚本中,“-a”或连字符/破折号 (-) 后面的任何字母叫什么?

问题描述 投票:0回答:1

下面是我项目中我试图理解的代码。谁能解释一下它叫什么? (-s 和 -a)

if [***-s*** $A ***-a -s*** $B] 

then ..

else ..

fi

还有,是否有一本字典,其中列出了所有 - 及其用法?

Google 搜索与我需要的信息不完全匹配。因为我不知道叫什么。请帮忙!

提前谢谢您!

shell unix
1个回答
1
投票

您正在寻找条件表达式。假设您使用的是 bash,您可以查看 Bash 参考手册的 6.4 Bash 条件表达式 部分。

-a file
True if file exists.

-b file
True if file exists and is a block special file.

-c file
True if file exists and is a character special file.

-d file
True if file exists and is a directory.

-e file
True if file exists.

-f file
True if file exists and is a regular file.

-g file
True if file exists and its set-group-id bit is set.

-h file
True if file exists and is a symbolic link.

-k file
True if file exists and its "sticky" bit is set.

[...]

请参阅上面引用的文档以获取完整列表。

© www.soinside.com 2019 - 2024. All rights reserved.