LinuxSir.cn,穿越时空的Linuxsir!

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

求如何判断一个文件是否存在

[复制链接]
发表于 2004-1-8 12:13:55 | 显示全部楼层 |阅读模式
#!/bin/sh
#watchdog.sh
files_watch=/wwwroot/herocenter/action/watchdog/dog_d.jpg
if [-r $files_watch];then
        rm -f $files_watch
        exit 1
else
        heroserver
fi

运行后总是提示
./watchdog.sh: [-r: command not found
发表于 2004-1-8 12:31:03 | 显示全部楼层
[ ]
should be [[ ]]
space before [[ and behind ]] is needed.

thus
if [[ -r $files_watch ]];then
发表于 2004-1-8 14:01:36 | 显示全部楼层
[ ]内的各项之间需要空格.
 楼主| 发表于 2004-1-8 14:47:50 | 显示全部楼层
谢谢了,原来是这样,现在可以了,感谢两位的帮助
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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