all repos — dotfiles @ 2a7af9e64a35386345d855e76f7e0ed58820a48f

linux dotfiles

bin/scripts/nping (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
#!/usr/bin/sh


if [[ $1 = "l" ]]; then
    while [ 1 ]; do
        ping -c 1 1.1.1.1 | awk 'NR==2 {print $(NF-1) " " $NF}' | 
            cut -d '=' -f2
        if [[ $2 -ne 0 ]]; then
            sleep $2
        else
            sleep 1 #default loop sleep
        fi
    done
elif [[ $1 = "ll" ]]; then
    while [ 1 ]; do
        ping -c 1 1.1.1.1 | awk 'NR==2 {print $(NF-1) " " $NF}' | 
            cut -d '=' -f2
    done;
else
    ping -c 1 1.1.1.1 | awk 'NR==2 {print $(NF-1) " " $NF}' | cut -d '=' -f2
fi