方法一:使用 find 和 xargs
find . -maxdepth 1 -type f -executable | xargs ldd
方法二:使用 for 循环
直接复制下面内容粘贴到命令行即可
for file in *; doif [ -f "$file" ] && [ -x "$file" ]; thenecho "Dependencies for $file:"ldd "$file"echo "-----------------------------"fi
done
解释:
find . -maxdepth 1 -type f -executable:在当前目录下查找所有可执行文件。xargs ldd:对每个找到的文件执行ldd命令。for file in *; do ... done:遍历当前目录下的所有文件。if [ -f "$file" ] && [ -x "$file" ]; then:检查文件是否为普通文件且可执行。ldd "$file":列出该文件的依赖库。
如果想仅保留not find的
ldd 的输出中,未找到的依赖通常会显示为 not found。你可以通过 grep 过滤出这些行。
for file in *; doif [ -f "$file" ] && [ -x "$file" ]; thenecho "Checking dependencies for $file:"ldd "$file" | grep "not found"echo "-----------------------------"fi
done