How can I use find, nm and grep to find a symbol among many shared libraries?

I am struggling with the right command to do the following:

find all shared libraries (* .so) containing a specific symbol.

Here's what I've tried:

find -iname '*.so*' -exec nm {} \; | grep -H _ZN6QDebugD1Ev

      

The above gives some output with the characters found, but does not specify the name of the file that the character was in. Any flag I give grep to tell it to print the filename is lost because grep is fed from stdin.

(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):0015e928 T _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev

      

Another try:

find -iname '*.so*' -exec nm {} \; -exec grep _ZN6QDebugD1Ev {} \;

      

This doesn't work because the two execs are completely independent.

What should I do?

+3


source to share


1 answer


Pass the "-A" option to nm, which will prefix its output with the filename. Then just grep for the character you are interested in, for example:



find -iname '*.so*' -exec nm -A {} \; | grep _ZN6QDebugD1Ev

      

+8


source







All Articles