web analytics

Using pattern lists in Unix

Here is the small reminder about the syntax of the “case” command and the usage of the pattern lists.

#!/bin/ksh
print -n "Please enter the line: "
read line

case "$line" in
 ?(dog|cat)  ) print "zero or one occurrence of any pattern" ;;
 *(low|high) ) print "zero or more occurrences of any pattern" ;;
 @(duncan|methos) ) print "exactly one occurrence of any pattern" ;;
 +(rudolph|blitzen) ) print "one or more occurrence of any pattern" ;;
 !(grinch|babay) ) print "everything except patterns" ;;
 -@([hH?]) )  print "Some help..." ;;
 -v*(erbose) ) print "Some more words..." ;;
 *) print "Something else..." ;;
esac

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.