Parse java console output with awk

Posted by Bob Rivers on Server Fault See other posts from Server Fault or by Bob Rivers
Published on 2010-06-11T18:49:43Z Indexed on 2010/06/11 18:53 UTC
Read the original article Hit count: 271

Filed under:
|

Hi,

I'm trying to use awk to parse an output generated by a java application, but it isn't working. It seems that the command after the pipe isn't able to get/see the data throwed by the java app.

I'm executing the following command (with the return generated by the command):

[root@localhost]# java -jar jmxclient.jar usr:pass host:port java.lang:type=Threading ThreadCount
06/11/2010 15:46:37 -0300 org.archive.jmx.Client ThreadCount: 103

What I need it's only the last part of the string. So I'm tryng to use awk (with pipe at the end of the line |awk -F ':' '{print $4}':

[root@localhost]# java -jar jmxclient.jar usr:pass host:port java.lang:type=Threading ThreadCount|awk -F ':' '{print $4}'

But the output isn't being parsed. It throws the entire string: 06/11/2010 15:46:37 -0300 org.archive.jmx.Client ThreadCount: 103

I also tryed to use |cut -f4 -d":" with the same result: the string isn't parsed.

So my question is, how do I parse the output in order to get just the number at the end of the string?

TIA,

Bob

© Server Fault or respective owner

Related posts about shell

Related posts about awk