What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



remove files and directories with acces time older than a given date

Terminal - remove files and directories with acces time older than a given date
find <dir> -printf '%p : %[email protected]\n' | awk '{FS=" : " ; if($2 < <time in epoc> ) print $1 ;}' | xargs rm --verbose -fr ;
2009-11-20 16:31:58
User: angleto
Functions: awk find rm xargs
remove files and directories with acces time older than a given date

remove files with access time older than a given date.

If you want to remove files with a given modification time replace %[email protected] with %[email protected] Use %[email protected] for the modification time.

The time is expressed in epoc but is easy to use any other format.


There are 2 alternatives - vote for the best!

Terminal - Alternatives
touch -t "YYYYMMDDhhmm.ss" ~/.ts ; find . -newer ~/.ts
2010-10-26 19:45:32
User: poffey21
Functions: find touch

This is great for looking for files that have been updated recently. Logs especially or monitoring what files were added during an install.

touch -t "YYYYMMDDhhmm.ss" dummy ; find . -anewer dummy
2009-11-21 04:05:45
Functions: find touch

touch a dummy file with the specified date, then use find with -anewer .

find -amin +[n] -delete
2009-11-20 17:15:28
User: TeacherTiger
Functions: find

Deletes files older than "n" minutes ago. Note the plus sign before the n is important and means "greater than n". This is more precise than atime, since atime is specified in units of days. NOTE that you can use amin/atime, mmin/mtime, and cmin/ctime for access, modification, and change times, respectively. Also, using -delete is faster than piping to xargs, since no piping is needed.

Know a better way?

If you can do better, submit your command here.

What others think

find -atime -delete

Comment by TeacherTiger 434 weeks ago


is not the same, atime allow to specify a delta expressed in days

The command I wrote allow to specify an exact date and time.

Comment by angleto 434 weeks ago

Then you can use "find -amin -n -delete", where n is the number of minutes in the past that the file was accessed. Note the minus sign before n is important (meaning "for less than n"). It's still not down to the second level, but usually you don't care about that, and this is *much* shorter and simpler.

Comment by TeacherTiger 434 weeks ago

again, the options -amin, -atime, -mtime, -mmin ... etc. allows only to specify a delta, you can ever calculate the delta, but with the command I wrote you don't need to do it.

For instance, if you want delete the files with access time older than 2009 10 21, you don't need to calculate how much is the delta between the access time of the files and the time of command execution.

Comment by angleto 434 weeks ago

Hi angleto,

I think your command is exactly whar I have been looking for. But unfortunately it is giving me an error on AIX find: 0652-017 -printf is not a valid option. Any suggestion?


Comment by rubenryhan 425 weeks and 3 days ago

Hi rubenryhan,

try to replace:

find -printf '%p : %[email protected]\n' | ...


find | xargs stat -c '%n : %Y' | ...

Comment by angleto 424 weeks and 1 day ago

Your point of view

You must be signed in to comment.