「ShellScript」until文で条件を判定するサンプル

2021年2月25日

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

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

x=21
until [ ! $x -lt 26 ]
do
    echo $x
    x=`expr $x + 2`
done

実行結果
$ sh test07.sh
21
23
25

shellscript

Posted by arkgame