Operating System - HP-UX
1834142 Members
2133 Online
110064 Solutions
New Discussion

using sed to display message

 
SOLVED
Go to solution
Adi_7
Frequent Advisor

using sed to display message

I want to grab the numbers from this string.
java version "1.1.6"
How do I do that?
Thanks.
5 REPLIES 5
Thierry Poels_1
Honored Contributor
Solution

Re: using sed to display message

hi,

num=(echo $string | cut -d" " -f3)
or
num=(echo $string | cut -c14- )

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Helen French
Honored Contributor

Re: using sed to display message

# echo java version "1.1.6" | awk '{print$3}'
Life is a promise, fulfill it!
curt larson_1
Honored Contributor

Re: using sed to display message

do you want the double quotes too?
if not
print $string | sed 's/[^"]*\"\([0-9.]\).*/\1/
or
print $sting | awk -F\" '{print $2;}'
Graham Cameron_1
Honored Contributor

Re: using sed to display message

Why not use the -F option to tell awk to deliit with quotes...

echo 'java version "1.1.6"'|awk -F\" '{print $2}'

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Laurent Menase
Honored Contributor

Re: using sed to display message

Hi,

In ksh or posix sh

b=${string#*\"}
echo ${b%\"*}