Last active
August 29, 2015 14:19
-
-
Save StryKaizer/e79e98aa7983b5fdaa7c to your computer and use it in GitHub Desktop.
Find similar files in directory based on a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Can be used to detect languages which lack translations in Commerce intl | |
# Usage: | |
# ./similar en.json - will compare all files in current dir with en.json | |
# ./similar en.json 5 - will compare all files in current dir with en.json | |
# and a threshold of under 5 lines being different before reporting | |
BASEFILE="$1" | |
LINE_DIFFERENCE_THRESHOLD=${2:-"40"} | |
for FILE in *.json | |
do | |
if [ "$BASEFILE" != "$FILE" ] | |
then | |
LINE_DIFFERENCE="$(diff -U 0 "$BASEFILE" "$FILE" | grep ^@ | wc -l)" | |
if [[ "$LINE_DIFFERENCE" -lt "$LINE_DIFFERENCE_THRESHOLD" ]] | |
then | |
FILE=${FILE%.json} | |
printf "'$FILE', " | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment