端末にこれを入力すると
test 4 -lt 6
私は何の結果も得られません。なぜできないの? 0または1が必要です。
ベストアンサー1
0または1を取得します。終了コードから。
bash-4.2$ test 4 -lt 6
bash-4.2$ echo $?
0
bash-4.2$ test 4 -gt 6
bash-4.2$ echo $?
1
修正する:後で使用するために終了コードを保存するには、変数に割り当てます。
bash-4.2$ test 4 -lt 6
bash-4.2$ first=$?
bash-4.2$ test 4 -gt 6
bash-4.2$ second=$?
bash-4.2$ echo "first test gave $first and the second $second"
first test gave 0 and the second 1