---
title: "用不同的执行方式来执行shell引起的问题"
author: "leibnitz"
date: "2011-12-11T14:59:07Z"
tags: []
categories: ["操作系统"]
slug: "shell"
draft: false
lastmod: "2011-12-11T14:59:07Z"
id: 1304962
url: "https://leibnitz.iteye.com/blog/1304962"
---

今天在执行shell时出现了奇怪的现象，同样的脚本在之前leibnitz下正常，但在vm下执行时提示：bad loop variable。

以下是語句：

for((i=0;i&lt;10;i++))

 ...

 

网站提示说要用dash执行，于是我在sh中添加了：#!/bin/bash，結果一样不行。

后来想到执行时我是用sh file执行的，于是改用了./file，灵了。

置于网站上说的sudo dpkg-reconfigure dash我倒没试过，影响启动速度 ？

 

see

[http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?topic\_id=5600](http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?topic_id=5600)

 

[http://hi.baidu.com/3800\_hk/blog/item/68373d6d9d53f4e7421694fa.html](http://hi.baidu.com/3800_hk/blog/item/68373d6d9d53f4e7421694fa.html)