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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
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.
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
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:
remove files with access time older than a given date.
If you want to remove files with a given modification time replace %A@ with %T@. Use %C@ for the modification time.
The time is expressed in epoc but is easy to use any other ordered format.
There is 1 alternative - vote for the best!
This is great for looking for files that have been updated recently. Logs especially or monitoring what files were added during an install.
touch a dummy file with the specified date, then use find with -anewer .
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.
If you can do better, submit your command here.
You must be signed in to comment.
find -atime -delete
@TeacherTiger
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.
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.
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.
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?
Thanks
Hi rubenryhan,
try to replace:
find -printf '%p : %A@\n' | ...
with:
find | xargs stat -c '%n : %Y' | ...