954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

awk help

Hi All,

I am trying to use awk to strip out the java version after I run the java -version command. Unfortunately nothing I try works. Here is the command I am running along with the output:

# /h/jre/bin/java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)

I am interested in just the 1.5.0_06 portion. Does anyone know how I can pipe this output to awk and have it return just that value?

Thx!
DY

dyoung02
Newbie Poster
2 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

I figured it out. If anyone is interested here is what I did:

/h/jre/bin/java -version 2> javaver.txt
JAVA=`more javaver.txt | awk '{print $3}'`
JAVA_VERSION=`echo $JAVA | awk '{print $1}'`

DY

dyoung02
Newbie Poster
2 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You