Bashスクリプトに2つの数値を追加する

Bashスクリプトに2つの数値を追加する

コマンドラインで2つの数字を追加しようとしていますが、出力が0の理由がわかりません。

#!/bin/bash

args=("$@") 



if [ ${args[0]} -eq ${args[1]} ]
then
echo "The sum of the 2 numbers is $(( arg[0] + arg[1] ))"
else
echo "The 2 numbers do not match, hence we are not adding up"
fi

ベストアンサー1

これは私にとって単純なタイプミスのようです。

おそらく$(( args[0] + args[1] ))そうではありません。$(( arg[0] + arg[1] ))

おすすめ記事