#!/bin/sh
INTERVAL=1
COUNT=0
while [ $COUNT -le 9 ]
do
((COUNT++))
sleep $INTERVAL
echo "count is $COUNT"
done
Bei der Ausführung.((COUNT ++)) -> "COUNT ++: nicht gefunden" im Shell-Skript
$ sh ascript
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
Arithmetische Substitution ist POSIX, nicht nur 'bash'. – geekosaur
Vielleicht ist OPs 'sh' dann nicht komplett POSIX - was ist der Unterschied? –
@geekosaur Ich glaube nicht, dass das nackte '(())' Konstrukt POSIX ist, obwohl '$ (())' ist. Zum Beispiel, "Dash" Drosseln auf OP-Skript in genau der gleichen Weise. – Clueless