Skip to content

Instantly share code, notes, and snippets.

@jvns

jvns/diff.sh Secret

Last active October 7, 2024 20:00
Show Gist options
  • Save jvns/c7272cfb906e3ed0a3e9f8d361c5b5fc to your computer and use it in GitHub Desktop.
Save jvns/c7272cfb906e3ed0a3e9f8d361c5b5fc to your computer and use it in GitHub Desktop.
#!/bin/bash
mkdir -p diffs/missing
find public -type f | grep html | while read -r file; do
relative_path="${file#public/}"
old_file="public_old/$relative_path"
diff_file="diffs/$relative_path"
mkdir -p "$(dirname "$diff_file")"
if [ -f "$old_file" ]; then
# diff --color=always -B -w "$old_file" "$file" > "$diff_file"
git diff --color=always --color-words --word-diff-regex=[^[:space:]] --no-index "$old_file" "$file" > "$diff_file"
#git diff --word-diff-regex=[^[:space:]] --no-index "$old_file" "$file" > "$diff_file"
else
echo "File $relative_path does not exist in public_old" > "diffs/missing/$relative_path"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment