页次: 1
shell(linux 条件测试)
文件的测试用来判读文件状态。比如是否存在, 是否目录,权限如何。
-e : 文件是否存在
-d :用来判读是否是目录
-f : 是否是普通文件
-s :文件如果是空的返回1 , 不是空的返回 0
[root@ippbs ~]# rm -f a.txt [root@ippbs ~]# touch a.txt [root@ippbs ~]# test -s a.txt [root@ippbs ~]# echo $? 1 [root@ippbs ~]# echo "ipbbs.net" > a.txt [root@ippbs ~]# test -s a.txt [root@ippbs ~]# echo $? 0
-w :是否可以写
-r :可以读
-x : 可以执行
-L :是否是连接符合
ipbbs.net
离线
页次: 1