2

これは私のコードです:

 nb_lignes=`wc -l $1 | cut -d " " -f1`
 for i in $(seq $(($nb_lignes - 1)) )
 do
 machine=`head $1 -n $i | tail -1`
 machine1=`head $1 -n $nb_lignes | tail -1`
 ssh  root@$machine -x " scp /home/file.txt root@$machine1:/home && rm -r /home/file.txt"
 done

scp et rmの前にfile.txtがそのようなマシンに存在するかどうかを確認したいのですが、このスクリプトを変更するにはどうすればよいですか?

ありがとうございました。

4

1 に答える 1

1

test次のコマンドを使用できます。test -f file && scp ...

     ssh  root@$machine -x " test -f /home/file.txt && scp /home/file.txt
root@$machine1:/home && rm -r /home/file.txt"
于 2012-10-20T11:08:12.250 に答える