LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 797|回复: 1

请教一个shell脚本的命令行参数问题

[复制链接]
发表于 2006-12-26 09:54:56 | 显示全部楼层 |阅读模式
bash-3.00# cat 1.sh
#!/bin/sh

echo \[$0\] number of args = $#
echo \[$0\] args = $*
./2.sh $*

bash-3.00# cat 2.sh
#!/bin/sh

echo \[$0\] number of args = $#
echo \[$0\] args = $*


bash-3.00# ./1.sh "\"hello world\" test"
[./1.sh] number of args = 1
[./1.sh] args = "hello world" test
[./2.sh] number of args = 3
[./2.sh] args = "hello world" test

我想让1.sh的命令行参数原封不动的传送给2.sh, 要怎么写?请大虾帮忙
发表于 2006-12-26 14:25:21 | 显示全部楼层
將 $* 改為 "$@" (不能省掉雙引號哦!)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表