Reputation: 4891
I need to create a bash script in order to return the ip of a process by using jps command.
How can i do that?
i have made so far:
#! /bin/bash
# script using jps a process id
jps #returns all the processes with ids and names
jps -l | grep javaNode #returns again a list of names with ids
#i need the output of a specific id
How can i do that?
Thanks, in advance
Upvotes: 0
Views: 597
Reputation: 34914
I will take a stab at what you want.
mynode="mynodename"
id=$(awk -vnode="$mynode" '$2 ~ node { print $1 }' <(jps -l))
echo $id
Upvotes: 1