Shell脚本test命令使用总结和实例

2019-09-23 09:36:40于丽

else
    echo 'The file does not exists!'
fi

输出:
The file already exists!

另外,Shell还提供了与( ! )、或( -o )、非( -a )三个逻辑操作符用于将测试条件连接起来,其优先级为:“!”最高,“-a”次之,“-o”最低。例如:


cd /bin
if test -e ./notFile -o ./bash
then
    echo 'One file exists at least!'
else
    echo 'Both dose not exists!'
fi

输出:
One file exists at least!