847 B
847 B
[
检查文件类型并比较值。 如果条件为真,返回状态0;如果条件为假,返回状态1。 更多信息:https://gnu.org/software/bash/manual/bash.html#index-test。
- 测试给定变量是否等于/不等于指定字符串:
[ "${{variable}}" {{=|!=}} "{{string}}" ]
- 测试给定变量是否[等于]/[不]等于/[大于]/[小于]/[大于或等于]/[小于或等于]指定数字:
[ "${{variable}}" -{{eq|ne|gt|lt|ge|le}} {{integer}} ]
- 测试指定变量是否具有[非]空值:
[ -n "${{variable}}" ]
- 测试指定变量是否具有空值:
[ -z "${{variable}}" ]
- 测试指定[文件]是否存在:
[ -f {{path/to/file}} ]
- 测试指定[目录]是否存在:
[ -d {{path/to/directory}} ]
- 测试指定文件或目录[是否]存在:
[ -e {{path/to/file_or_directory}} ]