EMACS中编写SHELL代码的问题

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
YinPSoft
帖子: 7
注册时间: 2009-02-03 0:57

EMACS中编写SHELL代码的问题

#1

帖子 YinPSoft » 2009-02-04 16:08

今天第一天学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"
YinPSoft
帖子: 7
注册时间: 2009-02-03 0:57

Re: EMACS中编写SHELL代码的问题

#2

帖子 YinPSoft » 2009-02-04 16:09

下面是错误信息:

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
YinPSoft
帖子: 7
注册时间: 2009-02-03 0:57

Re: EMACS中编写SHELL代码的问题

#3

帖子 YinPSoft » 2009-02-04 16:25

啊,我知道原因了。我在=号左右加了空格导致了这个问题
头像
renws
帖子: 64
注册时间: 2008-08-30 12:29
联系:

Re: EMACS中编写SHELL代码的问题

#4

帖子 renws » 2009-02-04 16:30

对shell不太熟悉,是不是不能有空行?
这样就OK了


#!/bin/sh
# 对变量赋值:
a="hello world"
# 打印变量a的值:
echo "A is:" $a
num=2
echo "this is the ${num}nd"
柔的法则
回复