The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
[sh] String comparison operators
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
[sh] String comparison operators
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
1
(
permalink
)
05-16-2008
userix
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?
userix
View Public Profile
Find all posts by userix
Find userix's past nominations received
Find userix's present nominations given