I've written a command line that effectively extracts the highest CPU java PID thread process from top -H (example code):
top -H -n 1 | grep "java" | head -n 1 | cut -d' ' -f1
I want to inspect the PID in jstack. Due to how fast the threads appear and disappear, it's not possible to enter the PID manually, and I was hoping to pipe the result directly into jstack, however whenever one does, for example (simplest code example that reproduces the issue):
12345 | jstack
jstack merely throws up the usage help page, as if pipe isn't sending the variable to jstack.
How can I get the PID I've got with my command into jstack?