LinuxSir.cn,穿越时空的Linuxsir!

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

这个sed语句用脚本写是什么样的啊,头疼...

[复制链接]
发表于 2010-6-7 17:39:09 | 显示全部楼层 |阅读模式
有这么一句, 在shell里执行正常,但在脚本里就不对提示
: No such file or directorylamp/apache2/conf/httpd.conf
  1. sed -i 's/^[[:space:]]*\(DirectoryIndex\).*\(index.html.*\)$/\1 index.php \2/g' /usr/local/lamp/apache2/conf/httpd.conf
复制代码
 楼主| 发表于 2010-6-7 17:41:12 | 显示全部楼层
不知道为什么,求解
回复 支持 反对

使用道具 举报

发表于 2010-6-7 23:33:22 | 显示全部楼层
No such file or directorylamp/apache2/conf/httpd.conf


你确认/usr/local/lamp/apache2/conf/httpd.conf  这个文件存在了吗,并且路径是正确的了吗?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-6-8 06:38:07 | 显示全部楼层
当然存在,我在shell里执行正常的,不知道为什么它把前面的路么给去掉了

: No such file or directory  lamp/apache2/conf/httpd.conf
回复 支持 反对

使用道具 举报

发表于 2010-6-8 09:22:11 | 显示全部楼层
完整的脚本是什么样的?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-6-8 09:29:29 | 显示全部楼层
问题找到了,我用sh -x运行脚本后,过程和预想的不符

[root@XH lamp]# sh -x p.sh

+ sed -i 's/^[[:space:]]*\(DirectoryIndex\).*\(index.html.*\)$/\1 index.php \2/g' $'/tmp/httpd.conf\r'

: No such file or directoryconf

$'/tmp/httpd.conf\r'   不明白这里的$'和后面的\r'怎么出来的,我重新手打了一遍就能运行了
回复 支持 反对

使用道具 举报

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

本版积分规则

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