linux - 循环运行 shell 脚本时出错

标签 linux shell unix

我写了这个 shellscript 文件。但是我得到 error near unexpected tokendone'`

#!/bin/bash
i=1
while [ $i -lt 12 ]; do
    echo Hi
    i=$[$i+1]
done

以前,do 之前没有;。我阅读了 stackexchange 答案并在 while [] 之后写了 ;,但我仍然收到错误。我无法在网上找到该解决方案。有任何想法吗?

最佳答案

i=$[$i+1] 这是错误的。你的意思可能是 i=$((i+1))

关于linux - 循环运行 shell 脚本时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27138946/

相关文章:

c++ - 使用 inotify 时缺少/dev/sdX 的通知

linux - 验证多个目录存在于其适当的分支上

python - 如何从 bash shell 执行 .py 脚本

php - UTF-8贯穿始终

c++ - 打开失败 : No such file or directory

macos - 协助使用安全授权或特权执行

c - 为什么 struct stat 中的 st_size 字段是有符号的?

java - 空字符串解析ntpq命令结果

linux - cygwin 的 Linux 版本?

c - 为什么我们使用零长度数组而不是指针?