怎么用shell判断一个文件是否存在
可以使用以下命令来判断一个文件是否存在:
if [ -f /path/to/file ]; then
echo "File exists"
else
echo "File does not exist"
fi
这里-f
选项用来判断文件是否存在且是普通文件。如果文件存在,则输出"File exists",否则输出"File does not exist"。可以根据实际情况修改路径和输出信息。
可以使用以下命令来判断一个文件是否存在:
if [ -f /path/to/file ]; then
echo "File exists"
else
echo "File does not exist"
fi
这里-f
选项用来判断文件是否存在且是普通文件。如果文件存在,则输出"File exists",否则输出"File does not exist"。可以根据实际情况修改路径和输出信息。
扫码添加客服微信