shell中怎么判断文件是否存在
在shell中可以使用-e
参数来判断文件是否存在。具体命令如下:
if [ -e file.txt ]; then
echo "File exists"
else
echo "File not found"
fi
其中file.txt
为要判断的文件名。如果文件存在,则会输出"File exists";如果文件不存在,则会输出"File not found"。
相关问答
在shell中可以使用-e
参数来判断文件是否存在。具体命令如下:
if [ -e file.txt ]; then
echo "File exists"
else
echo "File not found"
fi
其中file.txt
为要判断的文件名。如果文件存在,则会输出"File exists";如果文件不存在,则会输出"File not found"。
相关问答
扫码添加客服微信