How do i get last n line stack using pstack command?

1.2k views Asked by At

I am using pstack command in my c++ code and storing it in a string. The problem is it prints the stack upto last function and string becomes very heavy. Is there any way to print only last n lines of stack using pstack?

If it can't be done using pstack, then is there any other way to solve this purpose?

1

There are 1 answers

0
anshul garg On

You can redirect pstack output to a file then you can use tail -n to see last n lines

e.g.

pstack 243 > File.txt
tail -10 File.txt