And*_*rew 0 scripting bash shell-script
我想简单地0.050在 bash 脚本中重新分配一个变量(具体来说,将其增加)。在我编写的以下脚本中,i是(整数)索引,mytime是十进制/双精度/浮点数。“ps”(皮秒)是我在计算中使用的时间单位。
#!/bin/bash
mytime = 0.000
for i in {1..3}
do
echo "$i: $mytime ps"
mytime = mytime + 0.050
done
Run Code Online (Sandbox Code Playgroud)
但是,当我使用 运行此脚本时bash test.sh,会收到以下错误消息:
test.sh: line 2: mytime: command not found
1: ps
test.sh: line 6: mytime: command not found
2: ps
test.sh: line 6: mytime: command not found
3: ps
test.sh: line 6: mytime: command not found
Run Code Online (Sandbox Code Playgroud)
为什么它似乎被解释mytime为命令或函数,而不是变量?你能帮我纠正这个吗?
for i in $(seq 1 0.05 3); do
# loop body
echo i equals $i
done
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4231 次 |
| 最近记录: |