Answer the question
In order to leave comments, you need to log in
What are the pitfalls in such a bash instruction?
Runs on Ubuntu:
PROJECT_PATH="/var/www/..."
....
find $PROJECT_PATH -type d -mtime -3 -mtime +1 | head -n -1 | xargs rm -r
Answer the question
In order to leave comments, you need to log in
replace "xargs rm -r" with "xargs echo rm -r" and check.
What is the task?
So far, the task is strange:
Delete all directories in /var/www that are older than 1 day but younger than 3 days, while leaving one random directory (since the output is not sorted, and which directory will be skipped will be implicitly determined by what will find find first)?
If you just delete everything that is older than 1 day, then maybe like this:
PROJECT_PATH="/var/www/project1"
find $PROJECT_PATH -mtime +1 -delete
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question