Find and delete all core files

Locate and remove all core files in system using the find command.

find / -name core -exec rm {} \;

The find command replaces the {} characters in the command above with the filenames that it finds. You must include the \ immediately before the ; character.

See the comments for a more advanced method of accomplishing this.


About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.

3 Responses to “Find and delete all core files”

  1. October 23, 2008 at 3:31 pm, Stef said:

    sparkomemphis on has this example that will help prevent removing non-core files named (lets not argue that there should not be any of these) core.

    find . -name core* -user $USER -type f -size +1000000c -exec file {} ; -exec ls -l {} ; -exec printf “nny to remove this core filen” ; -exec /bin/rm -i {} ;


    • October 23, 2008 at 4:57 pm, Quinn McHenry said:

      I like that! Nice bit of code. Thanks for sharing!


  2. November 03, 2012 at 10:14 pm, richard said:

    find . -mount -name “core.[0-9]*” -print
    find . -mount -name “core.[0-9]*” -print -delete


Leave a Reply