If only for unsigned integers:
bash3
Code:
bash 3.2.25(1)$ [[ 12345x6 =~ [^0-9] ]]&&printf "No digit found: %s\n" "$BASH_REMATCH"
No digit found: x
Otherwise:
Code:
v="12345x6"
case $v in (*[!0-9]*) printf "No digit found: %s\n" "$v";;esac
For old, old sh use this syntax:
Code:
case $v in *[!0-9]*) printf "No digit found: %s\n" "$v";;esac
P.S. Just noticed "Bourne" If not bourne again 3, then [23]
Last edited by radoulov; 12-14-2007 at 01:06 PM..
|