引号内的Unix引文

时间:2014-01-21 13:00:12

标签: shell unix scripting

是否存在语法错误,其中$ DATE变量写在if语句中?

我在引号内引用时出现问题,这是代码

if [ \( ! -f "$CMD_FILE" \) -a \( $CMD_FILE == "myData"$DATE"D_1.zip" \) -a \( $TODAY == "Sat" \); then
touch /home/me/files myData"$DATE"_1.txt

1 个答案:

答案 0 :(得分:0)

你应该这样写:

if [ ! -f $CMD_FILE ] && \
[ $CMD_FILE == "myData"$DATE"D_1.zip" ] && \
[ $TODAY == "Sat" ]; then
    echo "yes";
fi

如果所有3个语句都为真,则脚本产生“是”