ADSM-L

Re: Need a quick help on a script.

2004-03-18 17:10:11
Subject: Re: Need a quick help on a script.
From: "Stephen E. Bacher" <seb AT DRAPER DOT COM>
To: ADSM-L AT VM.MARIST DOT EDU
Date: Thu, 18 Mar 2004 17:09:36 -0500
>>I need  to inspect a variable (the node name) for the first 2 characters
>>= LT or the first 5 characters = CLELT to do the script line otherwise
>>don't do the sscript line.

>It's stupid that UNIX doesn't have a simple way of doing this! Try:
>
>substring = `echo $variable | cut -c 1-2`
>if [[ "$substring" = "LT" ]]; then
>    ...
>
>If someone knows a simpler way to do this, that is also easy to understand,
>I would like to know about it!

This is what I usually like to do:

case "$variable" in
        LT*)    do this;;
        CLELT*) do that;;
        *)      do something else;;
esac

 - seb

<Prev in Thread] Current Thread [Next in Thread>