代码片段--批量生产库以及可执行文件的依赖关系

比如当前目录下有几个目录,其中存放了一些库和二进制工具,现在需要查看这些库以及二进制工具依赖那些动态链接库

#!/bin/bash

file=depend.txt
dir[0]="./bin"
dir[1]="./lib"
dir[2]="./sbin"

z="/*"

rm -rf $file

touch $file

for ((i=0;i<3;i++)); do

    file_list="`ls ${dir[${i}]}${z}`"
    echo -e "
Enter ${dir[$i]}
" >>$file

    for j in $file_list 
    do
        du -sh $j 1>>$file 2>/dev/null
        arm-hisiv100nptl-linux-objdump -x  $j 1>.tmp 2>/dev/null
        if [ $? = 0 ] ;then
            cat .tmp | grep NEEDED >>$file
            echo -e -n "
" >>$file
        fi
    done
    echo -e "

" >>$file
done

rm -rf .tmp

exit 0
原文地址:https://www.cnblogs.com/pengdonglin137/p/3480951.html