Skip to content

Instantly share code, notes, and snippets.

@devsekhar
Forked from thomasfr/what-changed.sh
Created July 20, 2018 07:23
Show Gist options
  • Save devsekhar/c3c75a512281dcc75adabcfd4f7cdb30 to your computer and use it in GitHub Desktop.
Save devsekhar/c3c75a512281dcc75adabcfd4f7cdb30 to your computer and use it in GitHub Desktop.
Recursively compare two directories and print which files have changed. Ignore binary files and do not show non existing files in `dir2`
#!/bin/bash
dir1="/tmp/dir1"
dir2="/tmp/dir2"
IFS=$'\n'
for file in $(grep -Ilsr -m 1 '.' "$dir1"); do diff -q --exclude="cache" "$file" "${file/${dir1}/${dir2}}" 2> /dev/null; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment