I am trying to compare files in two directories using rsync.
I am using the command to achieve this is like:
rsync -avcn folder1/* folder2/
The problem is the result also list all the directories, whereas I want to display on the list of files with difference.
How I can achieve this.
The -a
( --archive
) flag is doing too much in this case; it also wants to make the directory metadata (permissions, timestamps, user, group) equal. Use -r
instead; then rsync will only list those directories that exist in the folder1
but not in folder2
.
If you actually need some of the -a
behaviour, or you want to ignore directories even if they don't exist in folder2
, you can filter the output through grep
because directory names in rsync
's output conveniently end with a slash:
rsync -avcn folder1/* folder2/ | grep -v '/$'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.