LINUX.ORG.RU

История изменений

Исправление sin_a, (текущая версия) :

CHK_IP(){
    # usage:
    # CHK_IP ip 
    #
    IFS="." IPTEST=($1)
    unset IFS
    [[ "${IPTEST[0]}.${IPTEST[1]}.${IPTEST[2]}.${IPTEST[3]}" = "$IP" ]] || { echo "usage: CHK_IP ip"; exit 1; }
    for i in {0..3} ; do
        [[ "${IPTEST[$i]}" -gt 2 && "${IPTEST[$i]}" -lt 254 ]] || { echo "$1 is not ip address"; exit 1; }
    done
}   

Исходная версия sin_a, :

CHK_IP(){
    # usage:
    # CHK_IP ip varname filename
    #
    IFS="." IPTEST=($1)
    unset IFS
    [[ "${IPTEST[0]}.${IPTEST[1]}.${IPTEST[2]}.${IPTEST[3]}" = "$IP" ]] || { echo "usage: CHK_IP ip"; exit 1; }
    for i in {0..3} ; do
        [[ "${IPTEST[$i]}" -gt 2 && "${IPTEST[$i]}" -lt 254 ]] || { echo "$1 is not ip address"; exit 1; }
    done
}