Your request is a little odd (not that there's anything wrong with that). It seems odd to want to delete *everything* when the size reaches a certain level; usually people want to delete only the oldest files, keeping at least some recent files. But given that that is what you want, it is possible that 'find' is not the best tool for the job.
Note also that 'find' is kind of a weird language - you have to do a fair amount of reading and experimenting in order to become comfortable with it - especially if you are using it to delete files. So, if you don't need to learn 'find', it's probably better to leave that for another day.
That said, something like this (bash shell code) may be to your liking:
Code: Select all
set -- $(du -sk /path/to/directory)
[ $1 -gt 4000000 ] && rm -rf /path/to/directory
If this post appears in the wrong forums category, my apologies.