0

I am getting Getting (standard_in) 1: parse error with below code.

#!/bin/sh
base=01C71C
mid=0
end=0
for mid in {0..15..1}
do
 for end in {0..15..4}
 do
     if (( mid > 9 ))
     then
        mid_hex=`echo "obase=16;ibase=10; $mid" | bc`
     else
        mid_hex=$mid
     fi
     end_hex=`echo "obase=16;ibase=10; $end" | bc`
     reg=$base$mid_hex$end_hex
     phymem32 $reg >> osd.txt
 done
done

Please guide me where I am wrong and what alternatives can be made here to make it work same. Thank.

shah_pankil
  • 41
  • 1
  • 1
  • 5
  • Works for me. However `{0..15..1}` is a bash construct, so `#!/bin/sh` is probably the problem: `mid='{0..15..1}'; echo "obase=16;ibase=10; $mid" | bc` – glenn jackman Jan 12 '15 at 14:53

1 Answers1

1

Problem is this shebang:

#!/bin/sh

Since you're using BASH 4 specific feature i.e. {0..15..1} etc. You need to use:

#!/bin/bash
anubhava
  • 761,203
  • 64
  • 569
  • 643