Find core dumps
find . -type f -regex “.*/core.[0-9][0-9][0-9][0-9]$”
The regex in the above command matches the file name “core.xxxx” where “xxxx” is exactly four numbers 0-9. If the results look correct, we can delete all those dump files with the following command.
Find + Delete all core dumps found
find . -type f -regex “.*/core.[0-9][0-9][0-9][0-9]$” -exec rm {} ;
The one downfall of this method is that it’s slower, since regular expressions take time to process. But this is a small price to pay for getting rid of these files in large numbers safely. If you see any errors with the above code or have any experiences to share please leave a comment below.