SYSXPERTS Blog

Linux fundamentalist, Virtualization beadsman, and Storage agnostic

  • Subscribe

  • Blog Archives

  • Twitter

Extract values within quotes from command output on Linux using perl

Posted by sysxperts on May 21, 2010

For example:
To obtain all values within quotes from the output of a jstack command you could

./jstack [pid] |perl -lne ‘print $1 if (/”(.*)”/)’
or for just worker threads
./jstack [pid] |perl -lne ‘print $1 if (/”(Worker.*)”/)’

and if you wanted a count of how many quoted values there are

./jstack [pid] |perl -lne ‘print $1 if (/”(.*)”/)’ |wc -l

Leave a comment