shell while

#!/bin/sh

a=0
while [ $a -lt 5 ]
do
	echo $a
	a=`expr $a + 1`
done

[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
0
1
2
3
4

‘と`の違いで手古摺った.

#!/bin/sh

a=0
until [ ! $a -lt 5 ]
do
	echo $a
	a=`expr $a + 1`
done