"let" internal shell command doesn't work in a shell script?

Viewed 37029

I did

a=1234 
let "a=a+1"

on command line and it's fine. But when I do the same in a shell script. It prints out an error that "let: not found". Here is the script file.

#!/bin/sh
a=1234;
let "a=a+1";
echo "$a";

Thanks,

8 Answers
c=1
d=1
for i in `ls`
do
    if [ -f $i ]
    then
        echo "$c -> $i"
        c=`expr $c + 1`
    fi
done
c=`expr $c - 1`
echo no. of files $c
for i in `ls`
do
    if [ -d $i ]
    then
        echo "$d -> $i"
        d=`expr $d + 1`
    fi
done
d=`expr $d - 1`
echo no. of direcrories $d
Related