I have a java process containing multiple strings in the ps
output. I just want a particular string out of it.
For example, I have
root 5565 7687 0 Nov20 ? 00:00:54 /bin/java -Xms256m -Xmx512m -XX:MaxPermSize=128m -XX:PermSize=256m -XX:MaxPermSize=256m -Dstdout.file=/tmp/std.out -da -Dext.dir.class=profiles/ -Dprocess.name=java1 -Djava.security.policy=security.policy
I want just want process.name=java1
and require nothing else from the ps
output. I was unable to find a tangible way to do so using awk or sed.
I am tried to use:
ps -ef | grep java1 | grep -v grep | awk '/process.name/ {print $0}'
The output I get is the ps -ef
out.
Is there a simpler way?
Here is one way:
ps -ef | awk -F"process.name" '{split($2,a," ");print FS a[1]}'
process.name=java1