看起来它就像是一个倒置...
示例:
#!/bin/bash
set -x
#a=1
b=2
if [ "$a" -o -w "$b" ]; then
echo "ok"
else
echo "fail"
fi返回"fail“。
但我不确定,因为
#!/bin/bash
set -x
#a=1
#b=2
if [ "$a" -o -w "$b" ]; then
echo "ok"
else
echo "fail"
fi也会返回"fail“。如果打开replace -w!这将返回"ok“。
请给我看一下这个操作员的文件在哪里。Bash和sh手册只包含-a和-o操作符。
发布于 2014-10-20 03:11:51
这在man bash中有记录,同样的摘录也可以通过help test获得
-w FILE True if the file is writable by you.发布于 2014-10-20 03:11:26
它测试文件是否存在以及是否可写。阅读test命令的手册。
发布于 2014-10-20 19:24:17
只有一些额外的信息:
[ -e file ] : if "file" exists
[ -f file ] : if "file" exists and it is a file
[ -s file ] : if "file" exists and it is not empty
[ -d file ] : to check if "file" exists and it is a directory
[ -r file ] : if "file" exists and readable
[ -w file ] : if "file" exists and writable
[ -x file ] : if "file" exists and it is executable
[ -O file ] : if "file" exists and it is owned by current user
[ -G file ] : if "file" exists and default group same as the current user
[ file_1 -nt file_2 ] : if "file_1" newer than "file_2"
[ file_1 -ot file_2 ] : if "file_1" older than "file_2"https://stackoverflow.com/questions/26454260
复制相似问题