i am using SCO OpenServer 5
I wan to use bash and have a incrementing counter.
e.g.
#!/bin/bash
counter=1
let "counter+=1"
echo $counter
It says that it does not recognise let
So how should i do it?
i am using SCO OpenServer 5
I wan to use bash and have a incrementing counter.
e.g.
#!/bin/bash
counter=1
let "counter+=1"
echo $counter
It says that it does not recognise let
So how should i do it?
#!/bin/bash
counter=1
counter=`expr $counter + 1`
echo $counter
nope, does not work
result
1+1
> cat counter.bash
#!/bin/bash
counter=1
counter=`expr $counter + 1`
echo $counter
> bash counter.bash
2
Works for me, did you copy + paste it correctly?
Actually your original script works here, too; maybe you have a really old bash. The expr script should work regardless, though.
let is a built-in command, when we run it in script, it does not working. we can say subshell.
What can we do to run it in subshell.