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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM