Quote:
Originally Posted by
av_vinay
i=$[$i + 1];
#i=`expr $i +1`;
#i=`bc $i + 1`
#i=`($i+1 | bc)`
Those are all wrong.
$[$i + 1]; I don't even know what this is supposed to be
`expr $i +1` should have a space after the plus sign.
`bc $i + 1` does not work because bc reads its commands/data from files and standard input, not directly from the command line.
`($i+1 | bc)` tries to run a pipeline in a subshell and the first command's name is "$i+1", which most likely does not exist. What you want there is to echo into bc: `echo "$i+1" | bc`
If you continue to have problems, even with simple scripts, take a close look at the sh script file to see if there are any unwanted, unseen characters. You can use 'od -bc scriptfile' to take an unambiguous look. putty implies that windows is involved. If you are editing and/or copy-pasting in windows, there could be carriage returns in the file. If that's the case, use dos2unix or 'tr -d \\r' to remove them and try to run the resulting file.
If problems persist, please provide more info. /bin/sh alone doesn't say much. At minimum, specify which operating system and shell you are using.
Quote:
Originally Posted by
vgersh99
Actually, that arithmetic expansion is posix-compliant.
Regards,
Alister