Skip to content

Instantly share code, notes, and snippets.

@irisdyoung
Last active November 9, 2022 02:23
Show Gist options
  • Save irisdyoung/68bb60fe3109105959d87d32fbc77e1a to your computer and use it in GitHub Desktop.
Save irisdyoung/68bb60fe3109105959d87d32fbc77e1a to your computer and use it in GitHub Desktop.
Recursively diff a pair of files, to allow for the same lines to be in different orders without being marked as different
#! /bin/bash
recursive_diff() {
diff $1 $2 > tmptmptmp.diff
export diffsize=`ls -l tmptmptmp.diff | awk '{ print $5 }'`
while [ ! "$diffsize" == "$newdiffsize" ]; do
export diffsize=`ls -l tmptmptmp.diff | awk '{ print $5 }'`
cat tmptmptmp.diff | grep "^<" | cut -c 3- > tmptmptmp1.phil
cat tmptmptmp.diff | grep "^>" | cut -c 3- > tmptmptmp2.phil
diff tmptmptmp1.phil tmptmptmp2.phil > tmptmptmp.diff
export newdiffsize=`ls -l tmptmptmp.diff | awk '{ print $5 }'`
done
cat tmptmptmp.diff
rm tmptmptmp1.phil tmptmptmp2.phil tmptmptmp.diff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment