免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1595 | 回复: 1
打印 上一主题 下一主题

[文本处理] 【我不知道的小知识点】1.命令执行问题 [复制链接]

论坛徽章:
1
2015元宵节徽章
日期:2015-03-06 15:51:33
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-09-30 09:42 |只看该作者 |倒序浏览
本帖最后由 qimuzhi 于 2015-09-30 09:47 编辑

ligf@hot ~/tmp/shell/run-commands $ cat f.sh
#!/bin/bash -
#===============================================================================
#
#          FILE: f.sh
#
#         USAGE: ./f.sh
#
#   DESCRIPTION:
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: YOUR NAME (),
#  ORGANIZATION:
#       CREATED: 2015年09月30日 09:34
#      REVISION:  ---
#===============================================================================

CMD="ls && ls aaa && ls aasdf"
$CMD

ligf@hot ~/tmp/shell/run-commands $ ./f.sh
ls: cannot access &&: No such file or directory
ls: cannot access ls: No such file or directory
ls: cannot access aaa: No such file or directory
ls: cannot access &&: No such file or directory
ls: cannot access ls: No such file or directory
ls: cannot access aasdf: No such file or directory
ligf@hot ~/tmp/shell/run-commands $ ls && ls aaa && ls aasdf
f.sh
ls: cannot access aaa: No such file or directory
ligf@hot ~/tmp/shell/run-commands $
-------------------
上面的shell相信大家都看明白了吧?
这是为什么?script要如何才能实现和在terminal 直接敲命令的效果? 反之要如何?

论坛徽章:
20
卯兔
日期:2015-01-26 22:05:142015亚冠之萨济拖拉机
日期:2015-09-10 15:15:282015亚冠之阿尔希拉尔
日期:2015-09-25 17:37:53程序设计版块每日发帖之星
日期:2015-10-03 06:20:00程序设计版块每日发帖之星
日期:2015-12-09 06:20:00CU十四周年纪念徽章
日期:2015-12-17 09:07:15程序设计版块每日发帖之星
日期:2015-12-25 06:20:34程序设计版块每日发帖之星
日期:2015-12-25 06:20:34程序设计版块每日发帖之星
日期:2015-12-25 06:20:342015亚冠之广州富力
日期:2015-08-27 19:29:56每日论坛发贴之星
日期:2015-08-26 06:20:002015亚冠之阿尔希拉尔
日期:2015-05-18 17:26:27
2 [报告]
发表于 2015-09-30 09:58 |只看该作者
eval $CMD,要这样么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP