Re: Need a quick help on a script.
2004-03-18 17:10:11
>>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
|
|
|