在Linux shell脚本的for循环的语法 [英] syntax of for loop in linux shell scripting

查看:147
本文介绍了在Linux shell脚本的for循环的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有实施循环有问题。我得到这个错误,当我执行我的剧本

I have a problem implementing a for loop. I get this error when I execute my script

test1.sh:2:语法错误:坏的循环变量

test1.sh: 2: Syntax error: Bad for loop variable

我不明白这个错误。

这是我的剧本

#!/bin/bash
for (( c=1; c<=5; c++ ))
do
echo "Welcome $c times..."
done

任何一个可以告诉我的语法为SH环(在Ubuntu它链接到冲壳)在Ubuntu的壳呢?

can any one tell me syntax for for loop in sh(in ubuntu it links to dash shell) shell in ubuntu?

推荐答案

您可能与 SH 运行它,而不是庆典。尝试庆典test1.sh ./ test1.sh 如果是可执行文件,而不是 SH test1.sh

You probably run it with sh, not bash. Try bash test1.sh, or ./test1.sh if it's executable, but not sh test1.sh.

这篇关于在Linux shell脚本的for循环的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆