The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 12-14-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,915
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..