Linux判断远程服务器文件是否存在
有时候,我们需要对远程服务器文件进行相关操作,在此之前我们需要校验远程服务器文件是否存在。
#! /bin/bash
if ssh $1 test -e $2;then
echo '0'
else
echo '1'
fi
测试结果
[root@cchilei test]# sh fileExist.sh root@192.168.9.19 /testDir
0
[root@cchilei test]# sh fileExist.sh root@192.168.9.19 /opt/testDir
1

作者:cchilei
-------------------------------------------
个性签名:竹杖芒鞋轻胜马 一蓑烟雨任平生
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!

浙公网安备 33010602011771号