On Mon, Mar 18, 2013 at 12:46:51AM -0700, Linda Walsh wrote:
To do the above, you'd want to pre-init
(I'd use i=${1:?"need start count"} in bash, but don't know if that is portable)
so, assuming I know i is > 0:
i=$1; while $((i-=1)); do :; done
The $((...)) expansion is not a command, so you can't use it after a
"while" or "if". That's the role of ((...)) which, as already stated
several times in this thread, is *not* portable.
Personally, if I'm writing for POSIX sh, I'd do it this way:
i=$1
while [ $i -gt 0 ]; do
i=$((i-1))
done
Of course that's assuming it makes sense to count downward in the script.
If you have to count upward for application reasons, then obviously do
it in reverse.