ssh 远程执行多个命令,有通配符要使用双引号,没有则可以不用

#!/bin/sh

 for i in {2..25}
 do
        ip=10.161.21.$i
        echo $ip

        t=`ssh unicomlabs@$ip    "ls /home/unicomlabs/qq*|wc -l"`;
        echo "t=$t"
       #echo $ip >> ip10.161.21.txt;  echo "####################################################" >> ip10.161.21.txt;echo "####################################################" >> ip10.161.21.txt
        #t2=`ssh unicomlabs@$ip   cat /home/unicomlabs/ip2.txt|wc -l`;
        #t3=`ssh unicomlabs@$ip   cat /home/unicomlabs/ip3.txt|wc -l`;
        #t4=`ssh unicomlabs@$ip   cat /home/unicomlabs/ip4.txt|wc -l`;
        #t5=`ssh unicomlabs@$ip   cat /home/unicomlabs/ip5.txt|wc -l`;
        #t=$(($t1+$t2+$t3+$t4+$t5))
        #echo "$ip=$t";


done

 

#!/bin/sh

 for i in {2..25}
 do
        ip=10.161.21.$i
        #echo $ip
        t1=`ssh unicomlabs@$ip   cat /home/unicomlabs/ip1.txt|wc -l`;
       #echo $ip >> ip10.161.21.txt;  echo "####################################################" >> ip10.161.21.txt;echo "####################################################" >> ip10.161.21.txt
        t2=`ssh unicomlabs@$ip   cat /home/unicomlabs/ip2.txt|wc -l`;
        t3=`ssh unicomlabs@$ip   cat /home/unicomlabs/ip3.txt|wc -l`;
        t4=`ssh unicomlabs@$ip   cat /home/unicomlabs/ip4.txt|wc -l`;
        t5=`ssh unicomlabs@$ip   cat /home/unicomlabs/ip5.txt|wc -l`;
        t=$(($t1+$t2+$t3+$t4+$t5))
        echo "$ip=$t";


done

 

#!/bin/bash
for i in {2..25}
do
        ip=10.161.21.$i
        echo $ip
        ssh unicomlabs@$ip  "find /home/unicomlabs/*_bak5/output  -name '*.reading'|xargs -n1 rename '.reading' ''"
done

你可能感兴趣的:(linux,shell)