Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

copying/deleting directory and files since a time

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
antonio92m
Posts: 3
Joined: 2015-11-19 15:14

copying/deleting directory and files since a time

#1 Post by antonio92m »

Hello,

I was wondering if exist any command that I could use in a script where I want to copy/delete files and directories since a date. I know how to use commands such as
cp and rm but I don't know if there is any command that allows me directly to copy/erase since a time. The idea of this would be have a 1st hard drive where the data comes and leave it there for a time, after that erase all the content and copy it to another hard drive. So the 2nd hard drive has everything on it and the first only have the newest information.

I have done some scripts but nothing complicated. I'm asking here because I haven't found any command I could use for this.

Thanks beforehand,
Antonio

User avatar
pylkko
Posts: 1802
Joined: 2014-11-06 19:02

Re: copying/deleting directory and files since a time

#2 Post by pylkko »

like rsync? or like a snap shot?

http://www.admin-magazine.com/Articles/ ... or-Backups

Or perhaps snapshots on, say, btrfs?

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5346
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 13 times
Been thanked: 66 times

Re: copying/deleting directory and files since a time

#3 Post by dilberts_left_nut »

Use 'find' to, well, find what you want and the '-exec' parameter to do something to it.

Code: Select all

man find
AdrianTM wrote:There's no hacker in my grandma...

User avatar
kiyop
Posts: 3983
Joined: 2011-05-05 15:16
Location: Where persons without desire to improve themselves fear to tread, in Japan
Been thanked: 3 times

Re: copying/deleting directory and files since a time

#4 Post by kiyop »

dilberts_left_nut wrote:Use 'find' to, well, find what you want and the '-exec' parameter to do something to it.

Code: Select all

man find
+1

Be careful for files the name of which contain special characters such as space " ' \ ( ) { }

"-print0 | xargs -0" is useful sometimes.
Openbox, JWM: Jessie, Sid, Arch / Win XP (on VirtualBox), 10
http://kiyoandkei.bbs.fc2.com/

User avatar
cpoakes
Posts: 99
Joined: 2015-03-29 04:54

Re: copying/deleting directory and files since a time

#5 Post by cpoakes »

Re: find

Also take caution with the parameters to -mtime, the plus and minus may be counterintuitive.

Post Reply