Register
It is currently Wed Dec 13, 2017 10:28 pm

bash script - find command with delete and exec


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Thu Apr 06, 2017 7:49 am   

Joined: Tue Apr 12, 2016 4:11 am
Posts: 51
hi all,

i have devised a script that starts in /restored/ and in there, there are a lot of sub folders called peoples names and in the sub folders are files/folders and it deletes the data in the sub folders BUT not the sub folder itself and it should then touch a file in all the sub folders warning people files/folders get deleted in x days time

it all works apart from the touch command, if i change the mindepth to 1 it works but when i change it to 2 it doesnt

below is my script -

Code:
cd /restored/
find -mindepth 2 -exec rm -rf {} \;
find -mindepth 2 -type d -exec touch WARNING_everything_in_here_will_get_removed_in_14_days_time.txt {} \;


can anyone please help me out, i would be very gratefull

many thanks,

rob


Top
 Profile  
 PostPosted: Thu Apr 06, 2017 10:26 am   

Joined: Tue Apr 12, 2016 4:11 am
Posts: 51
got the stupid syntax wrong using the find touch command

Code:
cd /restored/
find -mindepth 2 -mtime +13 -exec rm -rf {} \;
find -type d -exec touch {}/WARNING_everything_in_here_will_get_removed_in_14_days_time.txt \;


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP