How to extract sub-string on bash-shell

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi everyone!
First of all, I'm sorry for asking about bash-script.

I want to extract "3.4.4".
I tried as follows.

/*Prompt*/
$arm-linux-gcc --version
arm-linux-gcc (GCC) 3.4.4
Copyright (C) 2004 Free Software Foundation, Inc.

/*Shell Script*/
CROSS_GCC=arm-linux-gcc
version=`$CROSS_GCC --version`

tmp=`expr "$version" : '\(.*(GCC) [0-9].[0-9].[0-9]\)'`
tmp2=`expr "$version" : '\((GCC) [0-9].[0-9].[0-9]\)'`


echo $tmp
echo $tmp2

/*Result of Shell Script*/
arm-linux-gcc (GCC) 3.4.4
                                        <= Nothing.

I want to extract "3.4.4" only.
How to use bash-script?

Help me~



Re: How to extract sub-string on bash-shell
On Wed, 25 Mar 2009 15:23:50 +0900, demiahn rearranged some electrons to
say:

Quoted text here. Click to load it

man awk

Re: How to extract sub-string on bash-shell
Quoted text here. Click to load it

We'll assume you're also sorry about multi-posting instead of
cross-posting.  I already answered your question in another
group.

--
Grant Edwards                   grante             Yow! Jesus is my POSTMASTER
                                  at               GENERAL ...
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline