nm
outputs a three-column format. I needed to get the set of defined symbols (in particular those that start with__
, in tracking down a C++ linking problem), which is the third column.awk
is good for that. Use$N
to get the nth column (zero-index). This pipeline did the trick:
nm ./oopack.o | awk '{print $2}' | sort | grep __(Thanks to DougEDoug for the pointer)