Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 2
    Can also add -maxdepth 1 to the find to stop recursion. Commented Apr 4, 2013 at 12:56
  • even this works. clean and simple!! Commented Apr 4, 2013 at 13:05
  • 2
    -delete is not portable if that matters, you can use -exec rm instead. Commented Apr 8, 2013 at 2:12
  • If rm !(*.c) generates event not found in bash, it needs to be proceeded with shopt -s extglob. Commented Mar 14, 2015 at 18:48
  • As usual, recommendation to first run without -delete to make sure you didn't make any potentially disastroud mistake. Commented Jun 1, 2016 at 7:41