0

Is there a way to just grep only changes ie; (add, delete, modified) and print path and file name using rsync.

I tried with below command but I am getting the path and file modified in separate line.

rsync -avnc $source $destination
source/10101/10102/10103/
source/10101/10102/10103/demo.fts

Note: There are more then thousands of sub directories in source, I want to print only files which are modified with absolute path.

1

You are getting the directory path since that directory differs in its timestamp or user/group settings or permissions compared to the directory at the target.

To stop rsync from looking at the directory timestamps, use the --omit-dir-times flag:

rsync -avc -n --omit-dir-times "$source/" "$target"

Note that rsync will not show the absolute paths of the files and directories, but the path relative to the top directory being transferred.

Using --itemize-changes (or -i) in place of --verbose (or -v), you get a lot more information about why a file is being updated on the target.

Example (with added annotations in the output):

$ rsync -ani s/ t
.d..t...... ./          # directory timestamp differs
>f+++++++++ file        # new file

$ rsync -a s/ t

$ touch s/file
$ rsync -ani s/ t
>f..t...... file        # file timestamp differs

$ echo hello >s/file
$ rsync -ani s/ t
>f.st...... file        # file size and timestamp differs

$ rsync -acni s/ t
>fcst...... file        # file size timestamp and checksum differs

$ rm s/file
$ rsync -acni s/ t
.d..t...... ./          # directory timestamp differs
$ rsync -acni --delete s/ t
*deleting   file        # file has been deleted in source
.d..t...... ./          # directory timestamp differs

See the documentation for the --itemize-changes option in the rsync manual on your system.

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.