Remove files created between certain time stamps.
11,129
Solution 1
If you can search for the first and last (chronological) directories you want to delete, then you can use find:
find . -newer first -not -newer last -type d
And if the output suits you, go for the delete
find . -newer first -not -newer last -type d -print0 | xargs -0 rmdir
or with explicit date stamps:
find . -newermt "2010-03-31 0300" -not -newermt "2010-03-31 0310" -type d
Solution 2
you can try this, if you are working in just one directory and the 5th field of the ls -ltrog
output is the time.
ls -ltrog | awk '$5~/03:0[0-9]/{$1=$2=$3=$4=$5="";gsub("^ +",""); cmd="rm \047"$0"\047";system(cmd) }'
Author by
Admin
Updated on August 17, 2022Comments
-
Admin over 1 year
Last night I had a script go a bit crazy and create a bunch of directories between 3:00 and 3:09am. Is there a quick one liner that will hunt these down and remove them for me?