I was reading this question but it hasn't answer, and the mine its different.

Linux: Trying to find files from a list recursively and copy them somewhere else

I'm trying to find the real files from symlinks of these files!.

$ 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"

For this question I was trying so shorter example:

$ sudo find -L /usr/lib64 -iname "libSM.so" -o -iname "libz.so" 
     -o -iname "libtiff.so.[3,5]" -exec cp {} /usr/copy \;

The folder empty.

$ 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 ..

The files to be copied

$ sudo find /usr/lib64 -iname "libSM.so" -o -iname "libz.so" -o -iname "libtiff.so.[3,5]"

The command!

$ sudo find /usr/lib64 -iname "libSM.so" -o -iname "libz.so" -o -iname "libtiff.so.[3,5]" -exec cp -L {} /usr/copy \;

The result!

$ 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

Only it's executing the copy for the last file found!!!

How do that?

  • Possible duplicate of Strange "find" behavior in linux Feb 16 '18 at 6:22
  • @KamilMaciorowski It's bad title for a question, how I need to looking for my question? 'something strange is happening'? The question must to be more descriptive about the goal, the fails and results, and the other post haven't these.
    – joseluisbz
    Feb 16 '18 at 10:45
  • What's your point? It's hard to name the issue unless you already know what the issue is. Note your current title is not perfect either, symlinks are completely irrelevant here. Feel free to improve any title. Your attitude seems somewhat defensive but my intention was to help you and future users to reach good answers and understand the subject. If I thought you hadn't researched enough then I would have voted your question down. Feb 16 '18 at 11:18
  • I can't change title of another person, for me this action is invasive, maybe inform the change the question to post owner. The point is, how to find something related in other post that hasn't clue? (In real World) do you not go to find a book for cooking in car shop.
    – joseluisbz
    Feb 17 '18 at 3:17
  • You can't compare the skills to find something where you have 11K when I have only 120. These site it's for expert people and newbie (I guess that)... I'm (riéndome) smiling about these comments.
    – joseluisbz
    Feb 17 '18 at 3:22

man find on my Kubuntu states:

Please note that -a when specified implicitly (for example by two tests appearing without an explicit operator between them) or explicitly has higher precedence than -o. This means that find . -name afile -o -name bfile -print will never print afile.

You need (escaped) parentheses:

sudo find /usr/lib64 \( -iname "libSM.so" -o -iname "libz.so" -o -iname "libtiff.so.[3,5]" \) -exec cp -L {} /usr/copy \;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.