I have a remote directory with read access. I want to generate a list of files that changed since last iteration.

My idea is something like:

$ cp output.new output.old
$ ll > output.new
$ diff output.new output.old > list.files

The idea is that list.files have just the name and relative path of new files or files with different "modified timestamp" like this:


So I'm asking about diff and ls parameters.

  • What exactly are you trying to do? regardless of what it is, diffing the outputs of ls -l is unlikely to be a robust way to do it - look at something based on rsync, inotify, or even find -mtime – steeldriver Jul 5 '18 at 14:43
  • I want to run a proccess every 10 minutes and proccess new or changes files. – Martin R. Jul 5 '18 at 15:00
  • 1
    find seems to be a much viable option. – Martin R. Jul 5 '18 at 15:01
  • See for example the highest-voted couple of answers at Script to monitor folder for new files? – steeldriver Jul 5 '18 at 15:09


if [ -f "$stampfile" ]; then
    find "$topdir" -type f -newer "$stampfile"

touch "$stampfile"

This little script would maintain a timestamp file that would get updated each time the script is run. It would find all files in the $topdir directory that has a modification timestamp newer than the timestamp file in $stampfile.

The first time this script is run, the timestamp file would not exist, so the script would not output anything. On subsequent runs, the script would list modified files since the last run.

  • I wanted to suggest something like this, but held off at remote directory with **read** access -- might be worth clarifying whether they can touch a remote file. – Jeff Schaller Jul 5 '18 at 16:13
  • 1
    @JeffSchaller The timestamp file would be written to some place with write access. The suggested set of commands in the question actually assumes write access in the directory, and also assumes direct access to it (possibly mounted, it doesn't say). This could be a script on a remote server, executed vie ssh as well. – Kusalananda Jul 5 '18 at 16:26
  • "find -newer" works like a charm! – Martin R. Jul 5 '18 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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