Skip to main content

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.
code:
declare -i year
otherwise use let assignments.

don't use $ variable name on lhs of =, e.g.
code:
d=27  #not $d=27
every if needs then.
every if gets 1 fi, e.g.
code:
if [ expr ]   elif [ expr ]   else  fi
put double-quotes around arithmetical expressions contain blank spaces, e.g.
code:
jahr="(( ((12 + $year / 100 - $year / 400 - ( 8 * $year / 100 + 13 ) / 25 ) % 30 + 19 * ($year % 19)) % 30 ))"
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.)

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

Popular posts from this blog

Some mp4 files not displaying correctly (CS6)

Thread: Samba is not authenticating with LDAP