OT: scripting help - can you check a string for starts with?

Jacques B. jjrboucher at gmail.com
Wed Dec 19 02:01:40 UTC 2007

On Dec 18, 2007 8:48 PM, James Pifer <jep at obrien-pifer.com> wrote:
> Need a bit of scripting help. I have a very small script with a case
> statement. The object of the case statement is derived from the
> dmidecode command to determine the type of machine it is, if possible.
> It works fine, but we're finding that a lot of the HP type machines
> respond with a model number plus other information. For example, we
> might get these two:
> HP Compaq dc7700 30GB6000
> HP Compaq dc7700 60GB6000
> Those are completely made up, the point being that we want to match on
> just "HP Compaq dc7700" and forget the rest.
> I'm pretty sure I can't do that from the case statement, but can it be
> done by an if/then? I've been googling and can't find a way, so I'm
> starting to think I can't.
> I have to do this from a bash script. I don't believe I use perl or
> anything like that for what we're doing.
> Any help is appreciated.
> Can anyone recommend a good book on bash scripting? There's probably
> quite a few, so I'd prefer to start with recommendations. Good chance
> it's been asked before so I'll try the archives too. A good website
> could be helpful to. Came across a few, but none that I thought were
> great.
> Thanks,
> James
> --
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

man cut

It will do it for you.  Use the cut command in your case statement, or
use the cut command before the case statement assigning the output to
a new variable and use that variable in the case statement.

Jacques B.

More information about the users mailing list