shell 脚本文件条件的手册页是什么

shell 脚本文件条件的手册页是什么

我知道有一个手册页描述了 *nix 系统上可用的文件条件。那个手册页是什么?

http://en.wikibooks.org/wiki/Bourne_Shell_Scripting/Control_flow#Test:_evaluating_conditions

上面的链接包含文件条件部分。这是我在系统上寻找的信息。

答案1

我通常参考的手册页是测试(1)

答案2

在里面man bash

这里是横截面:

Conditional Expressions

Conditional expressions are used by the [[ compound command and the test and [ builtin commands to test file attributes and perform string and arithmetic comparisons. Expressions are formed from the following unary or binary primaries. If any file argument to one of the primaries is of the form /dev/fd/n, then file descriptor n is checked. If the file argument to one of the primaries is one of /dev/stdin, /dev/stdout, or /dev/stderr, file descriptor 0, 1, or 2, respectively, is checked.

Unless otherwise specified, primaries that operate on files follow symbolic links and operate on the target of the link, rather than the link itself.

When used with [[, The < and > operators sort lexicographically using the current locale.

-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 is set-group-id.
-h file
True if file exists and is a symbolic link.
...

仅进行评估的另一种选择是man test仅进行条件评估。

相关内容