我正在尝试使用 shell 脚本将两个浮点数相加。我试过这个:
#!/bin/bash
if [ $# != 2 ]; then
echo "2 arguments are required "
exit
else
x=$1
y=$2
sum = $x + $y
echo ` sum = $sum | bc `
fi
Run Code Online (Sandbox Code Playgroud)
当我向命令行提供两个参数时,例如:
bash filename.sh 2.4 5
Run Code Online (Sandbox Code Playgroud)
...它给了我一个错误: [ 2 != 2 ] command not found