我正在阅读这个问题,但没有答案,而且我的答案有所不同。
我正在尝试从这些文件的符号链接中找到真正的文件!
$ sudo find /usr/lib64 -iname "libSM.so" -o -iname "libX11.so" -o -iname "libXinerama.so" -o -iname "libXxf86vm.so" -o -iname "libatk-1.0.so" -o -iname "libc.so.6" -o -iname "libcairo.so" -o -iname "libdl.so" -o -iname "libgcc_s.so.1" -o -iname "libgdk-x11-2.0.so.0" -o -iname "libgdk_pixbuf-2.0.so" -o -iname "libglib-2.0.so" -o -iname "libgmodule-2.0.so" -o -iname "libgobject-2.0.so" -o -iname "libgthread-2.0.so" -o -iname "libgtk-x11-2.0.so.0" -o -iname "libjpeg.so" -o -iname "libm.so" -o -iname "libpango-1.0.so" -o -iname "libpangocairo-1.0.so" -o -iname "libpng.so" -o -iname "libpthread.so.0 " -o -iname "librt.so" -o -iname "libstdc++.so.6" -o -iname "libtiff.so.[3,5]" -o -iname "libz.so"
对于这个问题我尝试了一个更短的例子:
$ sudo find -L /usr/lib64 -iname "libSM.so" -o -iname "libz.so"
-o -iname "libtiff.so.[3,5]" -exec cp {} /usr/copy \;
该文件夹为空。
$ ls -al /usr/copy/
total 0
drwxr-xr-x. 2 root root 6 Feb 15 22:39 .
drwxr-xr-x. 14 root root 167 Feb 15 21:33 ..
要复制的文件
$ sudo find /usr/lib64 -iname "libSM.so" -o -iname "libz.so" -o -iname "libtiff.so.[3,5]"
/usr/lib64/libz.so
/usr/lib64/libSM.so
/usr/lib64/libtiff.so.5
/usr/lib64/libtiff.so.3
命令!
$ sudo find /usr/lib64 -iname "libSM.so" -o -iname "libz.so" -o -iname "libtiff.so.[3,5]" -exec cp -L {} /usr/copy \;
结果!
$ ls -al /usr/copy/
total 884
drwxr-xr-x. 2 root root 46 Feb 15 22:39 .
drwxr-xr-x. 14 root root 167 Feb 15 21:33 ..
-rwxr-xr-x. 1 root root 419456 Feb 15 22:39 libtiff.so.3
-rwxr-xr-x. 1 root root 479440 Feb 15 22:39 libtiff.so.5
$
它仅执行找到的最后一个文件的复制!!!
怎么办呢?
答案1
man find
在我的 Kubuntu 上显示:
请注意,
-a
当隐式指定时(例如,两个测试之间没有显式运算符),或显式指定优先级高于-o
。这意味着find . -name afile -o -name bfile -print
永远不会打印afile
。
您需要(转义的)括号:
sudo find /usr/lib64 \( -iname "libSM.so" -o -iname "libz.so" -o -iname "libtiff.so.[3,5]" \) -exec cp -L {} /usr/copy \;