关于执行sh命令带参数

guotao1982 2006-06-16 11:33:36
各位大虾:
现有问题请教,如果我执行sh想带参数,传到shell脚本里面用如何处理?如:
sh hello.sh this is a test

helle.sh如下:
echo $test


执行上面那个命令,输出this is a test
...全文
713 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
leoyo 2006-06-19
  • 打赏
  • 举报
回复
setenv test 'this is a test'
guotao1982 2006-06-16
  • 打赏
  • 举报
回复
this is a test不是做为参数,而是做为hello.sh里面的$test的值
x86 2006-06-16
  • 打赏
  • 举报
回复
如果this is a test想作为一个参数,就加上引号
$1, $2, $3为第1,2,3个参数,以此类推
$#为参数个数

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧