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 -
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
I'm pretty sure some structuring of your text with e.g. punctuation would certainly enhance readability and understandability. And, posting WHAT "doesn't" could point helpers in the right direction. What be the difference when running it with mindepth 2 as compared to mindepth 1 ?
Would it help to put the {} in front of the file name to be touch ed?
As a safety measure ensure that the cd was successful.
if cd /restored/
then
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 \;
fi