My computer at work has a tendency to generate an excessive amount of core files, which can be useful for debugging, but slowly take up all of the available space on my computer. I made this command to delete all the core files, given that they all start with "core."
locate /core. | grep -v core.h | grep -v core.c | grep -v core.py \
| grep -v core.xml | grep -v core.txt | grep -v .gz \
| grep -v core.so | grep -v chrome |sudo xargs rm
It works, but it's unwieldy and would delete say core.sh if that file existed on my computer. I think a better way would be:
- Use locate to find all the files starting with "core."
- Feed that list into
file - Make a list out of everything that
filesays is a core file. Assuming that a file is a core file if and only if the output offile file_namecontains the phrase "ELF 64-bit LSB core file x86-64". - Feed that to
sudo xargs rm
But I don't know how to step three in that list.