简单的脚本问题……

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
jioyo源
帖子: 3476
注册时间: 2008-10-08 13:48

简单的脚本问题……

#1

帖子 jioyo源 » 2009-04-28 10:02

$ cat args
echo "$#"
for arg in "$*"
do
echo $arg
done


$ args 'e f ' g
2
e
f
g
为什么e f会分行显示?
上次由 jioyo源 在 2009-05-04 18:49,总共编辑 1 次。
--------------------------------------
论坛精华贴全集:http://forum.ubuntu.org.cn/viewtopic.php?f=48&t=199845
book:http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=198286
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 简单的脚本问题……

#2

帖子 eexpress » 2009-04-28 11:00

shell 改变的。分解参数了。
● 鸣学
头像
HFUTec
帖子: 48
注册时间: 2009-03-20 8:52

Re: 简单的脚本问题……

#3

帖子 HFUTec » 2009-04-28 12:44

我刚在我的ubuntu8.10上运行你的脚本,没发现这个问题啊
weicz
帖子: 49
注册时间: 2007-03-17 1:15

Re: 简单的脚本问题……

#4

帖子 weicz » 2009-04-28 16:15

2
e f g

我的结果是这样。。。。
debian lenny
头像
jioyo源
帖子: 3476
注册时间: 2008-10-08 13:48

Re: 简单的脚本问题……

#5

帖子 jioyo源 » 2009-04-28 23:31

eexpress 写了:shell 改变的。分解参数了。
意思shell对参数进行处理时去掉了单引号,然后被for分行输出.?
附件
Screenshot-20.png
Screenshot-20.png (4.9 KiB) 查看 849 次
--------------------------------------
论坛精华贴全集:http://forum.ubuntu.org.cn/viewtopic.php?f=48&t=199845
book:http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=198286
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

Re: 简单的脚本问题……

#6

帖子 bones7456 » 2009-05-04 13:15

bash?dash?
关注我的blog: ε==3
头像
jioyo源
帖子: 3476
注册时间: 2008-10-08 13:48

Re: 简单的脚本问题……

#7

帖子 jioyo源 » 2009-05-04 17:31

bones7456 写了:bash?dash?
bash
--------------------------------------
论坛精华贴全集:http://forum.ubuntu.org.cn/viewtopic.php?f=48&t=199845
book:http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=198286
头像
hellojinjie
帖子: 1150
注册时间: 2007-09-14 21:03
来自: 浙江

Re: 简单的脚本问题……

#8

帖子 hellojinjie » 2009-05-04 18:45

weicz 写了:2
e f g

我的结果是这样。。。。
debian lenny
我的结果和你一样
Say hello to everyday!
回复