#!/bin/bash
read -p "请输入目录加文件名: " file
#file="/usr/local/aaa.txt"
path=${file%/*}
if [ -f "$file" -a -s "$file" ];then
echo "文件存在,并且不为空"
size=`stat -c "%s" $file`
echo 文件大小为:"$size"
elif [ -f "$file" ] ;then
echo "文件存在,但是为空"
else
read -p "文件不存在,现在进行创建,请输入文件名: " Dateiname
cd $path&&touch $Dateiname
echo "创建成功"
fi
shell 获取服务器路径下文件是否存在并输出,如果存在则输出大小,不存在则创建
于 2021-09-07 11:31:17 首次发布