Skip to content

Instantly share code, notes, and snippets.

@yousry
Created October 8, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yousry/cc138d4c0e030e112419522f72a533be to your computer and use it in GitHub Desktop.
Save yousry/cc138d4c0e030e112419522f72a533be to your computer and use it in GitHub Desktop.
Collect all dynamic libraries for a linux binary
#!/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