shell-判断输入的文件是否存在
编写脚本:#!/bin/bash
#########用于用户输入的文件名是否存在
#########循环判断当前的目录下是否有与所输入同名的文件
echo "please input the filename:"
read -r filename
while [ ! -f $filename ];
do
echo "the file doesn't exit,please retry or input other filename"
read -r filename
done
echo "the file exits!"
给脚本find_file加可运行权限
chmod +x find_file
运行脚本:./find_file
页:
[1]