我已经编写了基于某个日期条件的清理活动脚本。但我得到一个错误。Bash - 语法错误:文件意外结束
#!/bin/bash
echo "Process Started"
Current_Date=`date +%Y-%m-%d`
echo "todays Date ==> $Current_Date"
fromDate=$1
toDate=$2
oldDate=`date --date="3 years ago" +%Y-%m-%d`
echo "Two Yrs Back Date ==> $oldDate"
if [ $toDate -le $oldDate ]
then
find . -type f -newermt $fromDate ! -newermt $toDate -exec truncate -s 0 {} \; && echo "truncated"
else
echo "todate should be less than three years"
fi
echo "Done"
得到的错误 - line 15: syntax error: unexpected end of file
虽然行15是不存在的脚本只有14行。此外,bash脚本运行良好,直到命令echo "Two Yrs Back Date ==> $oldDate"
。 之后它会在if
条件开始时给出错误。 只是想检查我正在做的任何语法错误。
引用所有的变数。 – 123
bash脚本运行良好,直到命令'echo“Two Yrs Back Date ==> $ oldDate”'之后,它在if条件开始时给出错误。 – Sam
'bash -n yourscpript'说什么?当你做'od -c yourscript'时,任何有趣的角色(\ r而不是\ n)? – Jens