其他分享
首页 > 其他分享> > 文件或目录是否存在

文件或目录是否存在

作者:互联网

#!/bin/bash



echo "basepath" $basepath
data_predict="/data/data_predict/"
data_predict_path=${basepath}${data_predict}
echo "data_predict_path" $data_predict_path

normal="normal.csv"
normal_file=${data_predict_path}${normal}
echo "normal" $normal_file

#判断目录是否存在,若不存在,则创建目录
if [ ! -d "$data_predict_path" ]; then
   mkdir "$data_predict_path"
fi
#判断文件是否存在,若不存在,则创建文件
if  [ ! -f "$normal_file" ];then
  touch "$normal_file"
fi

  

basepath /home/kg/qiaoruihua/jupyter_qiao/logistic_regression/gb_model
data_predict_path /home/kg/qiaoruihua/jupyter_qiao/logistic_regression/gb_model/data/data_predict/
normal /home/kg/qiaoruihua/jupyter_qiao/logistic_regression/gb_model/data/data_predict/normal.csv

标签:文件,normal,predict,是否,basepath,file,path,data,目录
来源: https://www.cnblogs.com/hapyygril/p/12049551.html