Hide

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.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.

Universal configuration monitoring and system of record for IT.
Hide

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:

Hide

News

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!
Hide

Top Tags

Hide

Functions

Hide

Credits

Find files changed between dates defined by ctime of two files specified by name

Terminal - Find files changed between dates defined by ctime of two files specified by name
find . -cnewer <file a> -and ! -cnewer <file b>
2012-08-15 21:57:42
User: rdc
Functions: find
1
Find files changed between dates defined by ctime of two files specified by name

This command finds all the files whose status has changed between the ctime of the older and newer .

Very useful if you can see from an ls listing a block of consecutive files you want to move or delete, but can't figure out exactly the time range by date.

Alternatives

There are 2 alternatives - vote for the best!

Terminal - Alternatives
find . -type f -newermt "2010-01-01" ! -newermt "2010-06-01"
2011-06-26 09:52:26
User: flatcap
Functions: find
Tags: find dates
31

Find files in a specific date range - in this case, the first half of last year.

-newermt = modification time of the file is more recent than this date

GNU find allows any date specfication that GNU date would accept, e.g.

find . -type f -newermt "3 years ago" ! -newermt "2 years ago"

or

find . -type f -newermt "last monday"
find /path/to/somewhere -newermt "Jan 1"
2014-02-02 18:02:07
User: renich
Functions: find
Tags: find
3

This command uses -newerXY to show you the files that are modified since a specific date. I recommend looking for "-newerXY" on the manpage to get the specifics.

touch -t 201001010000 begin; touch -t 201012312359.59 end; find . -newer begin -a ! -newer end
2011-06-22 20:09:05
Functions: find touch
Tags: find dates touch
1

Example above will recursively find files in current directory created/modified in 2010.

touch -t 197001010000 ./tmp && find . -newer ./tmp && rm -f ./tmp
2014-11-18 00:29:26
User: sergeylukin
Functions: find rm touch
-1

Sometimes you just want to operate on files that were created after specific date. This command consists of 3 commands:

- Create a dummy file with the custom date

- Find all files with "creation time" further than our custom date by using `-newer` find option. Add your crazy stuff here, like moving, deleting, printing, etc.

- Remove the dummy file

Know a better way?

If you can do better, submit your command here.

Your point of view

You must be signed in to comment.