脚本检查文件存在
这个问题在这里已经有了答案:
如果您的文件处于当前路径本身,则无需使用find
,以下可帮助您。
#!/bin/bash
filename=$1
if [[ -f "$filename" ]]; then
echo "file exists"
else
echo "file does not exists"
fi
然后以script.ksh file_name
运行脚本如果您需要验证文件是否存在并且具有某种大小,则在上面的代码中将-f
更改为-s
。
你也可以在你的盒子里进行man test
来检查所有这些情况。
上一篇: script checking file exists
下一篇: does file exist?