0

I want to find some functions or structures into library files. For this purpose I'm using "nm" command using "find" command output as parameter files. (I want search in /usr/lib directory recursively) I tried with this command without success:

nm -A | find /usr/lib -name "*.a" | grep "FunctionThatIWantFound"
Rubén Pozo
  • 1,035
  • 1
  • 12
  • 23
  • 2
    `find` doesn't read anything from standard input so it's not really clear what you expect this to accomplish. You want to run `nm -A` on the files reported by `find`? Or the output from `nm -A` should somehow be used by `find`? – tripleee Jan 03 '18 at 12:15
  • My intention was get find output as parameter – Rubén Pozo Jan 03 '18 at 12:27
  • That doesn't really clarify the question. Your answer runs `nm` on the files reported by `find` so if that's what you actually want, I guess we are done here; I'm mainly pointing out that your question is very unclear, and that we might be able to help clear up some misunderstandings if you could [edit] it to explain your thinking. – tripleee Jan 03 '18 at 12:34

1 Answers1

1

I have found a solution

nm -A $(find /usr/lib -name "*.a")| grep "fprintf"

or

find /usr/lib -name '*.a' -exec nm -A {} +| grep "fprintf"

thanks to @tripleee

Rubén Pozo
  • 1,035
  • 1
  • 12
  • 23
  • 2
    As a minor robustness tweak, `find /usr/lib -name '*.a' -exec nm -A {} +` avoids choking on nontrivial file names or too much output from `find`. The `-exec ... +` option might not be available in your `find`, though; as a fallback, `-exec ... \;` should work all the way back to the dark ages, but spawn more processes and hence run slower. – tripleee Jan 03 '18 at 12:36