スクリプト/コマンド入力
|
実行結果
|
Bシェル(bsh)スタイルの条件式
|
n=10
if [ $n = 10 ]; then
echo "\$n is 10";
else
echo "\$n is not 10";
fi |
$n is 10
|
n=100
if [ $n = 10 ]; then
echo "\$n is 10";
else
echo "\$n is not 10";
fi |
$n is not 10
|
n=100
if [ ! $n = 10 ]; then
echo "\$n is not 10";
else
echo "\$n is 10";
fi |
$n is not 10
|
n=10
nn=100
if [ $n = 10 -a $nn = 100 ]; then
echo "\$n is 10 and $nn is 100"
else
echo "\$n is not 10 or $nn is not 100"
fi |
$n is 10 and $nn is 100
|
n=10
if [ $n ]; then
echo "\$n is not null"
else
echo "\$n is null"
fi
|
$n is not null
|
Bashの条件式
|
if [ -f thefile ]; then
echo "thefile exists!";
else
echo "no thefile!";
fi |
thefile exists!
|