I need to delete all files in a directory that were created in 2009. What command can I use to do that?
Most filesystems don't store the creation time of a file, so the best you can do is check the last time the file was modified.
If you have a recent version of GNU find (e.g. on Linux or Cygwin) or FreeBSD or OSX, you can directly compare the date of a file with that of another file. In addition, these versions of find can use the file creation time (called its birth time, indicated with a
Run it once without
If your version of
Zsh's glob qualifiers can match files in a time interval, but the boundaries can only be indicated relative to the current date (e.g. N days ago).
You can also use timestamp files for precise dates, but you lose in terseness.
Since you phrased your question pretty much like a homework assignment, I'm going to leave a thorough read of the manual page as an exercise for the clued; this tutorial provided by @jfgagne should help quite a bit.