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

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

 



On Dec 18, 2007 8:48 PM, James Pifer <jep@xxxxxxxxxxxxxxxx> 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@xxxxxxxxxx
> 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.

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux