Thread: syntax error near unexpected token `('
hi there,
i've program define date of easter sunday year of choice.
i've written program in powershell, because in school have use ps.
have rewrite linux script, , i'm getting these 2 failure massages:
"./input-test: line 8: syntax error near unexpected token `(
./input-test: line 8: `$jahr=(( 12 + "$year" / 100 -"$year" / 400 - ( 8* "$year" / 100 + 13) / 25 ) %30 + 19* ( "$year" %19 )) %30 "
i've tried few things knowledge of linux still bit short hope guys can me bit.
code:
"
#!/bin/bash
echo "enter year"
read year
$jahr=(( 12 + "$year" / 100 -"$year" / 400 - ( 8* "$year" / 100 + 13) / 25 ) %30 + 19* ( "$year" %19 )) %30
$platzhalter = ("$year" %17)
if["$jahr" -eq 29]
$d=28
elseif ["$jahr" -eq 28 && "$plantzhalter" -ge 11]
$d=27
else [$d=$jahr]
fi
fi
fi
$e=(2*("$year"%4)+4*("$year"%7)+6*$d+(6+"$year"/100 -"$year"/400 -2)%7)%7
$tag=("$e" + "$d" +1)+21
if ["$tag" -gt 31]
$tag = $tag - 31
if ["$tag" -lt 10]
echo "ostersonntag fällt auf den 0$tag.04.$year"
else echo "ostersonntag fällt auf den $tag.03.$year"
fi
fi
"
hunting
thedawg
declare integer variables, e.g.
otherwise use let assignments.code:declare -i year
don't use $ variable name on lhs of =, e.g.
every if needs then.code:d=27 #not $d=27
every if gets 1 fi, e.g.
put double-quotes around arithmetical expressions contain blank spaces, e.g.code:if [ expr ] elif [ expr ] else fi
otherwise eliminate spaces , precede expression $code:jahr="(( ((12 + $year / 100 - $year / 400 - ( 8 * $year / 100 + 13 ) / 25 ) % 30 + 19 * ($year % 19)) % 30 ))"
(blank spaces offset outer double parens (( )) ok.)code:jahr=$(( ((12+$year/100-$year/400-(8*$year/100+13)/25)%30+19*($year%19))%30 ))
sure spelling of variable names consistent. (plantzhalter?)
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk syntax error near unexpected token `('
Ubuntu
Comments
Post a Comment