this post was submitted on 18 Aug 2024
34 points (94.7% liked)

Linux

5252 readers
173 users here now

A community for everything relating to the linux operating system

Also check out !linux_memes@programming.dev

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] LucidBoi@lemmy.dbzer0.com 4 points 3 months ago (3 children)

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 4 points 3 months ago (1 children)

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/ {} \;
[–] LucidBoi@lemmy.dbzer0.com 1 points 3 months ago

Oh the files don't have the date in their names. Is -name still gonna work with 'Aug 18'? I'm parsing for the date shown by -ls.

[–] rrconkle@lemmy.zip 3 points 3 months ago

Try swapping the positions of -name ‘*-FLAIR’ and -type d

[–] anzo@programming.dev 1 points 3 months ago (1 children)

Perhaps you need to use -ctime parameter on find command.

[–] LucidBoi@lemmy.dbzer0.com 1 points 3 months ago

That might be a lifesaver! I'll try it today. I also see there's a -cmin parameter which lets me be even more specific. Thanks