Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  shell  >  正文 shell判断文件是否存在(模板)的一段代码

shell判断文件是否存在(模板)的一段代码

发布时间:2014-09-20   编辑:www.jquerycn.cn
使用shell进行判断一个文件是否存在,如果不存在则创建它。

使用shell进行判断一个文件是否存在,如果不存在则创建它。
 

复制代码 代码如下:

#!/bin/bash
proclock(){
        if [ -e $1 ];then
                echo "this file is exist.."
        else
                echo "this file is not exist,but while be touch.."
                touch $1
        fi
}

read -p "please input the filename: "
DIR=`dirname $REPLY`
[ ! -d $DIR ] && mkdir -p $DIR
proclock $REPLY

您可能感兴趣的文章:
shell判断文件是否存在(模板)的一段代码
学习linux shell中 if else以及大于、小于、等于逻辑表达式
shell根据pid判断进程是否存在
WordPress常用的函数、方法汇总
shell判断文件,目录是否存在或具有权限的脚本
判断文件是否存在的shell脚本
shell判断文件是否存在的方法
shell编程中的条件测试语句
shell编程之条件测试语句教程
shell脚本判断文件相关属性的方法总结

[关闭]