以下是我的代码。
#!/bin/ksh
curdate=$(date '+%d%h,%Y')
while read line;
do
echo "$line" > new10.txt
str0=$(cut -f 2 new10.txt)
str01=$(cut -f 1 -d ',' new10.txt)
str1=$(cut -f 2 -d ',' new10.txt)
str2=$(cut -c 3 $str1)
if [ $str2=':' ];
then
str2=',2016'
finalstr=$str01$str2
if [ '01jan2017' -le $finalstr -le $curdate ];
then
finalstr1=$str01',2017'
else
finalstr1=$str01',2016'
echo $finalstr1 > datefinal.txt
fi
done < /export/home/islams/PISAS/userwiseutil/date.txt
我收到以下错误:
date1.sh:第22行:意外令牌done'
date1.sh: line 22:
附近的语法错误&lt; /export/home/islams/PISAS/userwiseutil/date.txt'
答案 0 :(得分:0)
#!/bin/ksh
curdate=$(date '+%d%h,%Y')
while read line;
do
echo "$line" > new10.txt
str0=$(cut -f 2 new10.txt)
str01=$(cut -f 1 -d ',' new10.txt)
str1=$(cut -f 2 -d ',' new10.txt)
str2=$(cut -c 3 $str1)
if [ $str2=':' ];
then
str2=',2016'
finalstr=$str01$str2
if [ '01jan2017' -le $finalstr -le $curdate ];
then
finalstr1=$str01',2017'
else
finalstr1=$str01',2016'
echo $finalstr1 > datefinal.txt
fi
fi #You missed this
done < /export/home/islams/PISAS/userwiseutil/date.txt
你错过了一个