• LucidBoi@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    I’m using “find . -name ‘*-FLAIR’ -type d -ls -exec cp -lr -t …/…/…/media_links/ {} ; | grep ‘Aug 18’” to make hardlinks for directories created on a certain date. However, I always get an error saying that it can’t create hardlinks for a folder that doesn’t even match the find criteria, while it works for the folders that I wanted. So, everything works, but I just wanna know why I’m getting that error. Any help? lmk if u need more info

    • Max-P@lemmy.max-p.me
      link
      fedilink
      arrow-up
      1
      ·
      3 months ago

      Your grep is getting the output of find piped into it, so there’s nothing in the find command itself (which has the -exec in there) to filter it down so it applies to everything find finds. You’re filtering for ‘Aug 18’ after find has already -exec the cp -ltr command.

      You probably want this:

      find . -name '*-FLAIR' -name '*Aug 18*' -type d -ls -exec cp -lr -t ../../../media_links/ {} \;