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