Newbie question, bash and find

Hey drop us a line about the show. Feel free to ask questions, provide feedback and criticism, or just ramble on about anything your little heart desires.

Moderators: snarkout, Patrick, dann

Post Reply
User avatar
Vogateer
Posts: 700
Joined: Thu Nov 17, 2005 11:18 pm
Location: Norman, Oklahoma
Contact:

Newbie question, bash and find

Post by Vogateer » Wed Oct 31, 2007 9:52 am

I haven't had much luck sorting this out or searching for the answer, so I thought I'd ask here.

I'm interested in concepts and occasionally I try to pick up some basic bash skills. I was essentially trying to use "find" to find all my podcast music files that were over 21 days old, and move them into a different directory while maintaining the directory structure. I was able to do something like:

Code: Select all

find ./ -type f -mtime +21 | cpio -pdmv ../Backups/Podcasts
This copies the files over while keeping the directory structure, but is there a way to move the files instead of copying them? Otherwise it seems like you should just copy and then delete the files, though it would be nice to make sure the copy works before deleting the files, which might require more bash trickery (using tests to make sure the file exists elsewhere before deleting?).
Vim is beautiful

Post Reply