Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In the Linux terminal, I'm using

diff --recursive --brief dir1 dir2

A couple of weeks ago, dir1 and dir2 were identical, but they have both been modified since then. I would like to order to outputs by the date of the last modification for the files in dir2 (or dir1, or whichever is more recent, or the time at which they began to differ).

I looked at the diff options and there doesn't seem to be a built in way to do any of these. Does anyone know a way?

share|improve this question

migrated from stackoverflow.com May 29 '13 at 2:21

This question came from our site for professional and enthusiast programmers.

    
maybe if you use find, then sort, then xargs? –  Szocske May 28 '13 at 19:37
    
I think it's time to put those directories under version control. (See: git) –  michael_n Sep 17 '13 at 8:18

1 Answer 1

No, of all diff options, there isn't a built in way to do any of the things your required. You have to coin your own solution.

This would be a fairly simple and straightforward solution to start with:

find /path/to/dir1  /path/to/dir2 -printf "%TY-%Tm-%Td %TH:%TM %p\n" | sort -r

what it gives you is a list of files in reverse chronically order.

  1. All the files that is newer than that a couple of weeks ago when dir1 and dir2 were identical are modified.
  2. The modified file that comes on the top of the list is modified more recently. E.g., if fileN in dir1 shows up higher than dir2, then fileN in dir1 is newer.

Is this good enough?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.