Returns the N most recently modified files from anywhere 'below' (and including) the current working directory, in order, with details.

nmf() { find . -type f -printf '%T@ ' -print0 -printf '\n' | sort -rn | head -"$1" | cut -f2- -d" " | tr -d "\0" | tr "\n" "\0" | xargs -0 ls -Ulh; }
Returns a list, with attributes (think `ls -l`), in reverse chronological order. N is a single numeric parameter. Robust against unfriendly filenames and directory structures.
Sample Output
gx@terra:/etc/apache2$ nmf 10
-rw-r--r-- 1 root root 7.2K Feb 16 01:02 ./apache2.conf
-rw-r--r-- 1 root root 1.8K Feb 16 00:58 ./envvars
-rw-r--r-- 1 root root  225 Feb 16 00:56 ./supysonic.conf
-rw-r--r-- 1 root root   17 Feb 16 00:54 ./conf-available/fqdn.conf
-rw-r--r-- 1 root root   59 Jul  2  2015 ./mods-available/php5.load
-rw-r--r-- 1 root root  897 Jul  2  2015 ./mods-available/php5.conf
-rw-r--r-- 1 root root   60 Nov 18  2014 ./mods-available/wsgi.load
-rw-r--r-- 1 root root 5.0K Nov 18  2014 ./mods-available/wsgi.conf
-rw-r--r-- 1 root root 3.4K Jan  7  2014 ./mods-available/ssl.conf
-rw-r--r-- 1 root root 6.3K Jan  7  2014 ./sites-available/default-ssl.conf

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands



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: