Created
October 8, 2016 15:44
-
-
Save yousry/cc138d4c0e030e112419522f72a533be to your computer and use it in GitHub Desktop.
Collect all dynamic libraries for a linux binary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# collectLibs.sh | |
# copy dynamic libraries for an application into a local lib folder | |
# The only argument is the filename | |
filename=$1 | |
lddraw=`ldd $1` | |
IFS=$'\n' read -rd '' -a lddlines <<<"$lddraw" | |
if [ ! -d "lib" ] | |
then | |
mkdir lib | |
fi | |
for lddline in "${lddlines[@]}" | |
do | |
libname=$(sed 's/.*=>//' <<< $lddline) | |
libname=$(sed 's/ (.*//' <<< $libname) | |
echo Copy: "$libname" | |
cp $libname ./lib | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment