how to delete all the files in a directory, but not the directory

sometimes i come across something so stupidly simple that i need to do, but i don’t know how to do it. today’s task was to delete everything in a directory recursively, but not the directory. i have never done that before and it didn’t seem like it would be that hard to do, but it took me a minute to figure it out.

it’s a little embarrassing, really, but:

delete everything in a directory, including the directory:
rm -rf directory/

delete everything in a directory, excluding the directory:
rm -rf directory/*

simple enough task, but it made me have to think and i don’t like thinking…it hurts my brain.

Twitter Weekly Updates for 2009-08-10

  • Just finished playoffs tonight. That's two rounds of vball today-once in the morning and once in the evening! Sooooo tired. #
  • read that a pregnant woman is supposed to drink half their pre-pregnancy body weight in ounces of water a day. i'm going to try that today. #
  • Express prepaid line at costco is longer than normal line #
  • Line getting out of costco is crazy too. I'm never getting out of here! #
  • I uploaded a YouTube video — koda at the ponds http://bit.ly/v9AjB #
  • Fire alarm went off at the office. Fire fighters are here now. http://twitpic.com/cvrfh #
  • All the nurses in our building were giggling like schoolgirls while posing with the fire fighters. http://twitpic.com/cvxpm #
  • Mint chip mocha ice blended coffee from it's a grind is FABULOUS! http://twitpic.com/cx8r4 #
  • Ugh. Tweaked my ankle this morning while taking the garbage out. #