Press "Enter" to skip to content

解决shell脚本for i in {0..10}输出{0..10}的问题

现象:

#!/bin/bash
for i in {0..10}; do
  echo $i;
done;

输出的却是{0..10}就这么一个字符串。

解决方案:

你执行这段文件用的不是bash,  是debian自己实现的dash(debian系的/bin/sh默认指向/bin/dash)

你可以直接

/bin/bash  example.sh

或者让sha-bang生效

chmod +x example.sh

./example.sh

注:本文转自https://blog.csdn.net/qingzhuyuxian/article/details/112367270

Be First to Comment

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注