Hi,
I am working on a ksh script and I´m stuck on the following:
I have to get the pthread_id from a procstack file for a particular tid#.
---------- tid# 1274057 (pthread ID: 1800) ----------
---------- tid# 1736913 (pthread ID: 4019) ----------
---------- tid# 1478705 (pthread ID: 4269) ----------
---------- tid# 1876087 (pthread ID: 4465) ----------
---------- tid# 1912849 (pthread ID: 3086) ----------
---------- tid# 425991 (pthread ID: 2828) ----------
---------- tid# 1954017 (pthread ID: 1543) ----------
---------- tid# 2064419 (pthread ID: 1286) ----------
---------- tid# 1491095 (pthread ID: 1029) ----------
---------- tid# 2265101 (pthread ID: 772) ----------
---------- tid# 418027 (pthread ID: 515) ----------
---------- tid# 1867819 (pthread ID: 258) ----------
---------- tid# 2281679 (pthread ID: 1) ----------
---------- tid# 1851497 (pthread ID: 2571) ----------
---------- tid# 2199627 (pthread ID: 2314) ----------
---------- tid# 450699 (pthread ID: 2057) ----------
I can grep the output file by "tid#" or by the tid# number itself, but what I would like to obtain is the pthread ID. Lets say, I have tid# 1876087 to grep by.
Variable pthread identifies currently the whole line that contains my $TID:
echo pthread=`cat "${OM}_procstack_${PID}.txt" | grep $TID`
---------- tid# 1876087 (pthread ID: 4465) ----------
Can somebody help me to cut the 4465 from this line? I would like to put it into a variable so I can use it.
---------- tid# 1876087 (pthread ID: 4465) ----------
Both numbers on the line (tid# and pthread ID) can vary in length, and I can´t just awk and call it $6 because I do not want the ')' after it. Also, I think you awk files, not lines nor variables, right?
I do not want *everything from ':' to ')' * as there are a varying number of spaces, so I´m not sure how to go about this. I am sure one of you is going to make this sound so easy-peasy in a minute..
/
Thanks in advance!
T.