無法通過tcsh執行IF語句。 這對我來說工作正常 -tcsh中的IF語句錯誤
#!/bin/bash
if echo `cal|tail -6|sed -e 's/^.\{3\}//' -e 's/.\{3\}$//' |tr -s '[:blank:]' '\n' | head -11|tail -10|tr -s '\n' ' '`|grep -w `date "+%e"`
then
echo "present"
else
echo "absent"
fi
這就是問題所在 -
#!/bin/tcsh
if echo `cal|tail -6|sed -e 's/^.\{3\}//' -e 's/.\{3\}$//' |tr -s '[:blank:]' '\n' | head -11|tail -10|tr -s '\n' ' '`|grep -w `date "+%e"`
then
echo "present"
else
echo "absent"
endif
得到這個錯誤 -
if: Expression Syntax.
then: Command not found.
我真的需要使用 「tcsh的」 運行
確保您的腳本實際上以'.csh'擴展名結尾,而不是'.sh'。這對我來說是個問題 – krb686