如果测试为真,如何使用简单的单行测试并执行多个命令?以下不起作用:
for f in $source_dir/*.mov
do
[ ! -f "$f" ] && echo "No files in source directory. Exiting."; break || continue
# a bunch of commands
done
我使用下面的代码让它工作,但我觉得应该有更简单的方法。
for f in $source_dir/*.mov
do
if [ ! -f "$f" ]; then
echo "No files in source directory. Exiting."
break
else
# a bunch of commands
fi
done