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 -->
  #1 (permalink)  
Old 05-16-2008
userix userix is offline
Registered User
  
 

Join Date: May 2008
Posts: 21
[sh] String comparison operators

I know in C shell, if I wanted to check if the inputted number was in a certain format, like a zip code, I can use the following code:

Code:
if ( $reply !~ [0-9][0-9][0-9][0-9][0-9] ) then

Now if I wanted to do the same thing in bourne shell script, I assume it would be something like this:

Code:
if [ $reply! = [0-9][0-9][0-9][0-9][0-9] ]

but this doesn't work when I tested it out. Does bourne shell support regex in if statement conditions?