Extract values within quotes from com...

Extract values within quotes from command output on Linux using perl

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

 ./jstack <pid> |perl -lne 'print $1 if (/"(.*)"/)' 

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

 ./jstack 23545 |perl -lne 'print $1 if (/"(.*)"/)' |wc -l

No comments: