拷贝所有可执行文件的依赖共享库脚本: cpld.bash
1、cpld.bash脚本内容如下:
\#===================================================
function useage()
{
cat << EOU
Useage: bash $0
EOU
exit 1
}
\#Validate the inputs
[[ $# < 2 ]] && useage
\#Check if the paths are vaild
[[ ! -e $1 ]] && echo "Not a vaild input $1" && exit 1
[[ -d $2 ]] || echo "No such directory $2 creating..."&& mkdir -p "$2"
\#Get the library dependencies
echo "Collecting the shared library dependencies for $1..."
deps=$(ldd $1 | awk 'BEGIN{ORS=" "}$1\
~/^\//{print $1}$3~/^\//{print $3}'\
| sed 's/,$/\n/')
echo "Copying the dependencies to $2"
\#Copy the deps
for dep in $deps
do
echo "Copying $dep to $2"
cp "$dep" "$2"
done
echo "Done!"
2、使用方法
bash cpld.bash <可执行文件名> <要保存依赖库的目录>
for example:
bash cpld.bash demo /home/temp/
评论已关闭