if语句中的多个负表达式在bash脚本中不起作用

if语句中的多个负表达式在bash脚本中不起作用,bash,Bash,我正在尝试在下面的if语句中测试一个文件夹的所有权、目录和可写性,该语句在bash脚本中正常工作 if [ -O ./testDir -a -d ./testDir -a -w ./testDir ] then echo "All is well" else echo "All not ok"| mail -s "Folder Issue" -r "xyz<xyz@xyz.com>" xyz@xyz.com fi if[-O./testDir-a-d./

我正在尝试在下面的if语句中测试一个文件夹的所有权、目录和可写性,该语句在bash脚本中正常工作

if [ -O ./testDir  -a  -d ./testDir  -a -w ./testDir ]
then
    echo "All is well"
else
    echo "All not ok"|  mail -s "Folder Issue" -r "xyz<xyz@xyz.com>" xyz@xyz.com 

fi
if[-O./testDir-a-d./testDir-a-w./testDir]
然后
呼应“一切都好”
其他的
回显“全部不正常”|邮件-s“文件夹问题”-r“xyz”xyz@xyz.com 
fi
然而,我想用下面的语句替换上面的if语句,这是不起作用的;如果我在不同的if语句中测试每个条件,它会工作得很好

if [ !  -O ./testDir  -a ! -d ./testDir  -a ! -w ./testDir ] 
then
    echo "All not ok"|  mail -s "Folder Issue" -r " xyz<xyz@xyz.com>" xyz@cisco.com 

fi
if[!-O./testDir-a!-d./testDir-a!-w./testDir]
然后
回显“全部不正常”|邮件-s“文件夹问题”-r“xyz”xyz@cisco.com 
fi
如果我做错了,请帮忙

not( expr1 and expr2 and expr3 )
与等于:

(not expr1) or (not expr2) or (not expr3)
因此,你应该选择:

if [ !  -O ./testDir -o ! -d ./testDir -o ! -w ./testDir ]
与等于:

(not expr1) or (not expr2) or (not expr3)
因此,你应该选择:

if [ !  -O ./testDir -o ! -d ./testDir -o ! -w ./testDir ]
插入!在下列情况之后:

if ! [ -O ./testDir  -a  -d ./testDir  -a -w ./testDir ]
插入!在下列情况之后:

if ! [ -O ./testDir  -a  -d ./testDir  -a -w ./testDir ]