1 2 3 4 5 6 7 8 9
#!/bin/sh lib=$1; shift nm=$1; shift ar=$1; shift grepit=`echo $* | sed 's/ /\$|__imp__/g'` [ -n "$grepit" ] && grepit="__imp__$grepit\$" objs=`$nm $lib | awk -F: '/^d*[0-9][0-9]*.o:/ {obj=$1} '"/$grepit/"'{print obj}'` [ -n "$objs" ] || exit 1 $ar ds $lib $objs