String Manipulation in Bash

Posted by user348000 on Stack Overflow See other posts from Stack Overflow or by user348000
Published on 2010-05-22T20:35:54Z Indexed on 2010/05/22 20:40 UTC
Read the original article Hit count: 152

Filed under:
|

Hello-
I am a newbie in Bash and I am doing some string manipulation.

I have the following file among other files in my directory:

jdk-6u20-solaris-i586.sh

I am doing the following to get jdk-6u20 in my script:

myvar=`ls -la | awk '{print $9}' | egrep "i586" | cut -c1-8`
echo $myvar

but now I want to convert jdk-6u20 to jdk1.6.0_20. I can't seem to figure out how to do it.

It must be as generic as possible. For example if I had jdk-6u25, I should be able to convert it at the same way to jdk1.6.0_25 so on and so forth

Any suggestions?

© Stack Overflow or respective owner

Related posts about bash

Related posts about solaris