#!/bin/sh ip=1.2.3.4 if expr "$ip" : '[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*$' >/dev/null; then echo "success" else echo "fail" fi