使用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