Hi,
i'm new and i'm coding a little bash for serial check:
#!/bin/sh
#!/bin/bash
serial=$(grep -w "Serial" /proc/cpuinfo)
match="Serial : 000000000ca1d574"
if [ $serial = $match ] ; then
echo "ok"
else
echo "no"
fi
But if i run sh ./filename.sh i've this error:
./filename.sh: line 11: syntax error: unexpected "fi" (expecting "then")
why? you can help me 
Thank you.
1 Like
faser
2
Tried without the space before the ;
if [ "$serial" = "$match" ] ; then
i've tryed to make this change but i get the same error:
filename.sh: line 9: syntax error: unexpected "fi" (expecting "then")
#!/bin/sh
#!/bin/bash
serial=$(grep -w "Serial" /proc/cpuinfo)
match="Serial : 000000000ca1d574"
if [ "$serial" = "$match" ] ; then
echo "ok"
else
echo "no"
fi
hnyman
5
Have you installed bash?
(By default there is only ash from busybox providing sh functionality, but no bash compatibility)
And in any case, you have conflicting double shebang:
Both sh and bash defined ????
ok i've modified the sh:
#!/bin/sh
serial=$(grep -w "Serial" /proc/cpuinfo)
match="Serial : 000000000ca1d574"
if [ "$serial" = "$match" ] ; then
echo "ok"
else
echo "no"
fi
root@Speezy:~# sh ./filename.sh
./filename.sh: line 8: syntax error: unexpected "fi" (expecting "then")
system
Closed
9
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.