Skip to content

Instantly share code, notes, and snippets.

@gnanet
Created March 4, 2016 19:22
Show Gist options
  • Select an option

  • Save gnanet/91f86f52660287a0b754 to your computer and use it in GitHub Desktop.

Select an option

Save gnanet/91f86f52660287a0b754 to your computer and use it in GitHub Desktop.
diff nonbinary oneliner recursive
#!/bin/bash
#
# diff two folders located in the same parent-folder
# look for binary files in both, exclude txt|css|tpl|php if they contain binary stings (like foreign language)
oldpath=old/
newpath=new/
if [ ! -d ${oldpath} ]; then echo "${oldpath} is not a folder"; exit ; fi
if [ ! -d ${newpath} ]; then echo "${newpath} is not a folder"; exit ; fi
#
# If you use this as a oneliner replace ${oldpath} and ${newpath} with the folder names
#
excludes=`grep -ILsr -m 1 '.' ./ | sed -e "s/^.*\.//g" | sort | uniq | egrep -v "txt|css|tpl|php" | awk {' printf "-x *."$1" " '}; echo` ; diff -Naur -iEwB ${excludes} ${oldpath} ${newpath}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment