「ShellScript」while文のサンプル

2021年2月25日

書式
while [ 条件 ]
do 処理コード done
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#!/bin/sh
x=11
while [ $x -lt 15 ]
do
echo $x
x=`expr $x + 1`
done
#!/bin/sh x=11 while [ $x -lt 15 ] do echo $x x=`expr $x + 1` done
#!/bin/sh

x=11
while [ $x -lt 15 ]
do
    echo $x
    x=`expr $x + 1`
done

実行結果
$ sh test06.sh
11
12
13
14

shellscript

Posted by arkgame