在运行这个bash脚本时,我会收到错误。我查过所有的手册了,我觉得还好吧?
帮助感激。
#!/bin/sh
HOME=/var/www
sleep 20
echo 'running' > $HOME/script-1-output.txt
if (-f $HOME/script-2-output.txt )
echo 'script-2 has run' >> $HOME/script-1-output.txt
else
echo 'script-2 has not run' >> $HOME/script-1-output.txt
fi
if (-f $HOME/script-3-output.txt)
echo 'script-3 has run' >> $HOME/script-1-output.txt
else
echo 'script-3 has not run' >> $HOME/script-1-output.txt
fi发布于 2013-09-10 23:39:22
在bash中,如果条件被包装在[] not ()之间。在条件和方括号之间应始终留有空格。然后你需要用“如果-然后-其他-fi”的语法。
if [ -f file.txt ]; then
echo "yes"
else
echo "no"
fihttps://stackoverflow.com/questions/18730368
复制相似问题