经典面试题-搜狐&和讯网Shell面试题

搜狐&和讯网

问题1:Shell脚本里如何检查一个文件是否存在?如果不存在该如何处理?

#!/bin/bash

if [ -f file.txt ]; then
   echo "文件存在!"
else
   echo "文件不存在!"
fi
发布了1706 篇原创文章 · 获赞 1763 · 访问量 16万+

猜你喜欢

转载自blog.csdn.net/weixin_42528266/article/details/105053773