#!/bin/sh
INTERVAL=1
COUNT=0
while [ $COUNT -le 9 ]
do
((COUNT++))
sleep $INTERVAL
echo "count is $COUNT"
done
実行中。((COUNT ++)) - > "COUNT ++:見つかりません"シェルスクリプト
$ 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
算術置換は 'bash'だけでなくPOSIXです。 – geekosaur
OPの 'sh'は完全にPOSIXではないかもしれません - 違いは何ですか? –
@geekosaur '(())'構造はPOSIXであるとは思えませんが、 '$(())'はあります。例えば、 'dash'は全く同じ方法でOPのスクリプトについています。 – Clueless