OT: scripting help - can you check a string for starts with?
wwp
subscript at free.fr
Wed Dec 19 18:55:49 UTC 2007
Hello James,
On Wed, 19 Dec 2007 12:17:21 -0500 James Pifer <jep at obrien-pifer.com> wrote:
> Thanks to all that replied. My final solution is if/then/else's. Not as
> efficient as a case but does the job, and I can look for the substrings
> that I need using:
>
> if echo "$SYSTEMNAME" | grep -q "HP Compaq dc7700"
> then
> blah blah blah
>
> Thanks,
> James
>
Many ways to do it, bash also allows substring matching: ${FOO:n[m]}
For instance:
LINE=$(whatever command gives your chars to filter out)
MATCH="HP Compaq dc7700"
if [ "${LINE:0:${#MATCH}}" == "$MATCH" ]
then
..
fi
Regards,
--
wwp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20071219/3b142ff4/attachment-0001.sig>
More information about the fedora-list
mailing list