Yup, that’s an excellent solution. I would change the -name thusly:
‘(’ -name core -o name ‘core.[0-0]*’ ‘)’
This picks up both ‘core’ files and core.nnnn files, which are often also generated by appending the PID (see /proc/sys/kernel/core_pattern and man core(5) for more). Also, -atime +3 checks for files that haven’t been accessed in 3 days.
And yes, escaping the -exec command in find is a gnarly thing, something I can never keep straight!
Yeah, I considered that but “went literal” on the problem.
One small nit (and we are talking really, really small) is that -atime +3 looks for *greater* than 3 days so to get an inclusion of *exactly* three days I inverted the whole thing.
3 Comments
Depends on what you mean by “touched”, but something like:
find ~ -name core -type f ! -atime -3 -exec rm -f {} \;
should work for everything from $HOME on down.
Depending on your shell you may need to escape certain things.
Yup, that’s an excellent solution. I would change the -name thusly:
‘(’ -name core -o name ‘core.[0-0]*’ ‘)’
This picks up both ‘core’ files and core.nnnn files, which are often also generated by appending the PID (see /proc/sys/kernel/core_pattern and man core(5) for more). Also, -atime +3 checks for files that haven’t been accessed in 3 days.
And yes, escaping the -exec command in find is a gnarly thing, something I can never keep straight!
Yeah, I considered that but “went literal” on the problem.
One small nit (and we are talking really, really small) is that -atime +3 looks for *greater* than 3 days so to get an inclusion of *exactly* three days I inverted the whole thing.
Post a Comment