Eu acabei fazendo isso em python.
#!/usr/bin/env python2
from subprocess import PIPE, Popen
def is_core_file(filepath):
''' Use file command to determine if something is an actual core file.'''
prog = Popen(["file", filepath], stdin=PIPE, stdout=PIPE)
out = prog.communicate()[0]
return "core file" in out
def main():
prog = Popen(["sudo", "updatedb"], stdin=PIPE, stdout=PIPE)
prog.communicate()
prog = Popen(["locate", "/core."], stdin=PIPE, stdout=PIPE)
cores = prog.communicate()[0].split('\n')
for core in cores:
if is_core_file(core):
print("deleting " + core)
prog = Popen(["sudo", "rm", "-f", core])
if __name__ == '__main__':
main()
Editado para usar main.