bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what matched in a case statement


From: Bob Proulx
Subject: Re: what matched in a case statement
Date: Wed, 14 May 2008 01:08:03 -0600
User-agent: Mutt/1.5.13 (2006-08-11)

Poor Yorick wrote:
> Is there any way to get a handle on what matched in a case
> statement?  Something like this:
> 
> case "lawlesspoets" in
>         *poets)
>                 echo $CASEMATCH one
>                 ;;
>         lawless*)
>                 echo $CASEMATCH two
>                 ;;
> esac

Perhaps matching again?

  foo="lawlesspoets"
  case $foo in
    *poets)
      echo ${foo/*poets/one}
      echo ${foo%poets} one
      ;;
    lawless*)
      echo ${foo/lawless*/two}
      echo ${foo#lawless} two
      ;;
  esac

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]