Skip to content

Instantly share code, notes, and snippets.

@bebehei
Created May 1, 2017 10:11
Show Gist options
  • Save bebehei/f61e14893a8939f2b48ee071c880f58b to your computer and use it in GitHub Desktop.
Save bebehei/f61e14893a8939f2b48ee071c880f58b to your computer and use it in GitHub Desktop.
Get average of linked libraries in your $PATH.
#!/bin/bash
# 'ldd % | wc -l | grep -v ^1$'
# ^ if file is not a dynamic linked executable, ldd will print one line on STDOUT, but we have to ignore this
find $(echo $PATH | tr : ' ') -mindepth 1 -maxdepth 1 \
| xargs -I% bash -c 'ldd % | wc -l | grep -v ^1$' \
while read line;\
do l=$((l + line));\
done \
&& echo $l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment