[root@qls /service/scripts]# cat file.sh
#!/bin/bash
read -p "请输入一个文件名称:" File
if [ -z $File ];then
echo "文件名不能为空!请重新输入!"
exit
fi
if [[ $File =~ ^[/] ]];then
if [ -f $File ];then
echo "文件${File}存在!"
else
echo "文件${File}不存在!"
fi
else
echo "文件路径必须使用绝对路径!"
fi