ocehb: (Default)
ocehb ([personal profile] ocehb) wrote2014-01-29 03:01 pm
Entry tags:

Вычисление параметров в zsh

В zsh можно вычислять параметры с помощью флага e:

# a="\$RANDOM"; print -l $a ${(e)a} ${(e)a}
$RANDOM
497
31298
#



# cat rping.zsh
#! /bin/zsh -f
rounds=$1; shift
for n in {1..$rounds}; do
   print ping -c3 ${(e)@[$n%$#+1]}
done
# zsh rping.zsh 10 '192.168.$[$RANDOM%17].$[$RANDOM%255]' '10.8.1.$[$RANDOM%255]' 
ping -c3 10.8.1.41
ping -c3 192.18.13.151
ping -c3 10.8.1.28
ping -c3 192.18.0.148
ping -c3 10.8.1.196
ping -c3 192.18.5.129
ping -c3 10.8.1.107
ping -c3 192.18.0.149
ping -c3 10.8.1.72
ping -c3 192.18.16.15

попеременно пингуем адреса в двух сетках.



Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org