gpt4 book ai didi

linux - 从 ldd 输出复制所有共享对象

转载 作者:行者123 更新时间:2023-12-01 21:22:44 25 4
gpt4 key购买 nike

如何从可执行文件的 ldd 输出中复制所有共享对象?

我正在寻找这样的东西,但这是用于 find 的,我需要 ldd:

find -name "*python3.7*" -exec cp "{}" /home/user/python/arm-linux-gnueabihf/ \;

编辑:

ldd 输出示例:

adrian@adrian:~/Dokumenty/PracaMagisterska/eclipse/0_FULL_GAME$ ldd 0_FULL_GAME
linux-vdso.so.1 (0x00007ffcc15fc000)
libsfml-window.so.2.5 => /usr/lib/x86_64-linux-gnu/libsfml-window.so.2.5 (0x00007ff1f8d57000)
libpython3.8.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (0x00007ff1f8809000)
libsfml-system.so.2.5 => /usr/lib/x86_64-linux-gnu/libsfml-system.so.2.5 (0x00007ff1f87fb000)
libsfml-graphics.so.2.5 => /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2.5 (0x00007ff1f87a3000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff1f85c2000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff1f8473000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff1f8456000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff1f8264000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007ff1f8127000)
libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007ff1f811a000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007ff1f8092000)
libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007ff1f8066000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007ff1f8036000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff1f801a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff1f7ff7000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff1f7ff1000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007ff1f7fec000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007ff1f7f2d000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff1f8e00000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007ff1f7f01000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007ff1f7eec000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007ff1f7ce2000)
libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007ff1f7c2a000)
libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007ff1f7bf6000)
libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007ff1f7bbc000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007ff1f7bb6000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007ff1f7bae000)
libbsd.so.0 => /usr/lib/x86_64-linux-gnu/libbsd.so.0 (0x00007ff1f7b94000)

最佳答案

上面的示例 ldd 输出被保存到“infile”。描述:运行 awk 以选择具有 4 个字段的行,并 echo 将 lib 从第三个字段复制到目标目录的命令:

awk 'NF == 4 { system("echo cp " $3 " destdir") }' infile

不是从 infile 中读取,而是可以将 ldd 的输出通过管道传输到 awk 中,例如:

ldd 0_FULL_GAME | awk 'NF == 4 { system("echo cp " $3 " destdir") }'

将 destdir 替换为您选择的目录。一旦显示的命令看起来正常,删除 echo 以实际复制,例如:

ldd 0_FULL_GAME | awk 'NF == 4 { system("cp " $3 " chosen-dir") }'

关于linux - 从 ldd 输出复制所有共享对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63660871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com