I have a log file as the following. Each line logs some string and the thread id. Each thread belongs to a process and a process can have N threads.
Based on the following sample, I want to extract (using bash tools, grep
, sed
and whatever) all the lines of all threads that belongs to a given process. Note that the process is mentioned only once, at the top of a thread sequence:
line1 thread= 150 process= 200
line2 thread= 152 whatever
line3 thread= 150 whatever
line4 thread= 150 whatever
line5 thread= 130 whatever
line6 thread= 130 process= 200
line7 thread= 150 process= 201
line8 thread= 130 whatever
line9 thread= 130 whatever
For this sample, give process 200
the output should be:
line1 thread= 150 process= 200
line3 thread= 150 whatever
line4 thread= 150 whatever
line6 thread= 130 process= 200
line8 thread= 130 whatever
line9 thread= 130 whatever