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 UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 05-16-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Basic Bourne doesn't have regular expressions in the [ command, no. You can use case in this case (sic) though.

Code:
case $reply in [0-9][0-9][0-9][0-9][0-9]) rejoice;; esac
The case statement uses basic glob patterns, not full regular expressions. The expr command supports regular expressions, and many modern Bourne-compatible shells have extensions which add regex support to the shell itself.
Reply With Quote