shell中怎么判断文件是否存在

   2024-10-13 5150
核心提示:在shell中可以使用-e参数来判断文件是否存在。具体命令如下:if [ -e file.txt ]; thenecho File existselseecho 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"。

 
举报打赏
 
更多>同类维修大全
推荐图文
推荐维修大全
点击排行

网站首页  |  关于我们  |  联系方式网站留言    |  赣ICP备2021007278号