Show last changed files in a directory

ls -t | head
This will quickly display files last changed in a directory, with the newest on top.
Sample Output
$ ls -t | head
distroversions.txt
craigslist.txt
sql-bench
Bonnie.4539
dental.txt
vulnkb_v2.xml
error.log
asdf.txt

2
2012-01-17 16:28:32

These Might Interest You

  • Lists ONLY the files changed by the given HASH/HEAD/list of hashes, etc. The message, commit ID, author, etc. is not included


    2
    git show --relative --pretty=format:'' --name-only HASH
    lingo · 2009-08-14 03:36:03 0
  • Only shows files with actual changes to text (excluding whitespace). Useful if you've messed up permissions or transferred in files from windows or something like that, so that you can get a list of changed files, and clean up the rest.


    1
    git diff --numstat -w --no-abbrev | perl -a -ne '$F[0] != 0 && $F[1] !=0 && print $F[2] . "\n";'
    lingo · 2009-08-19 05:07:58 2
  • Parse the output of git status. Once the line '# Changed but not updated:' has passed print every last part of the line if it exists on disk.


    0
    git status | perl -F'\s' -nale 'BEGIN { $a = 0 }; $a = 1 if $_ =~ /changed but not updated/i; print $F[-1] if ( $a && -f $F[-1] )'
    coffeeaddict_nl · 2010-10-15 07:58:14 1
  • This command is meant to be used to make a lightweight backup, for when you want to know which files might be missing or changed, but you don't care about their contents (because you have some way to recover them). Explanation of parts: "ls -RFal /" lists all files in and below the root directory, along with their permissions and some other metadata. I think sudo is necessary to allow ls to read the metadata of certain files. "| gzip" compresses the result, from 177 MB to 16 MB in my case. "> all_files_list.txt.gz" saves the result to a file in the current directory called all_files_list.txt.gz. This name can be changed, of course. Show Sample Output


    2
    sudo ls -RFal / | gzip > all_files_list.txt.gz
    roryokane · 2009-12-14 21:40:56 0

What Others Think

This is more nicely formatted: ls -lat | head I prefer to use: ls -latr
qiet72 · 334 weeks and 6 days ago

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: