今天第一天学SHELL,遇到一个非常郁闷的问题,为什么一个简单的赋值语句都不能运行呢?请问是什么原因?
我看的是http://wiki.ubuntu.org.cn/Shell%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80的教程,代码也是跟着它写的啊?
代码如下:
# !/bin/sh
# Set value to a var
a = "hello ubuntu
# print the value of the var
echo "a is :" $a
num = 2
echo "this is the ${num}nd"
EMACS中编写SHELL代码的问题
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
-
- 帖子: 7
- 注册时间: 2009-02-03 0:57
-
- 帖子: 7
- 注册时间: 2009-02-03 0:57
Re: EMACS中编写SHELL代码的问题
下面是错误信息:
Comint started at Wed Feb 4 16:06:01
/home/yinpsoft/learning/shell/firstshell.sh
/home/yinpsoft/learning/shell/firstshell.sh: line 3: a: command not found
a is :
/home/yinpsoft/learning/shell/firstshell.sh: line 7: num: command not found
this is the nd
Comint finished at Wed Feb 4 16:06:01
Comint started at Wed Feb 4 16:06:01
/home/yinpsoft/learning/shell/firstshell.sh
/home/yinpsoft/learning/shell/firstshell.sh: line 3: a: command not found
a is :
/home/yinpsoft/learning/shell/firstshell.sh: line 7: num: command not found
this is the nd
Comint finished at Wed Feb 4 16:06:01
-
- 帖子: 7
- 注册时间: 2009-02-03 0:57
Re: EMACS中编写SHELL代码的问题
啊,我知道原因了。我在=号左右加了空格导致了这个问题
- renws
- 帖子: 64
- 注册时间: 2008-08-30 12:29
- 联系:
Re: EMACS中编写SHELL代码的问题
对shell不太熟悉,是不是不能有空行?
这样就OK了
#!/bin/sh
# 对变量赋值:
a="hello world"
# 打印变量a的值:
echo "A is:" $a
num=2
echo "this is the ${num}nd"
这样就OK了
#!/bin/sh
# 对变量赋值:
a="hello world"
# 打印变量a的值:
echo "A is:" $a
num=2
echo "this is the ${num}nd"
柔的法则