#!/bin/bash # This script will do a filtered diff on two files, and check for changes # If there are changes it will clear the screen, display the diff, # And provide a select list as follows: # 1) cp file1 file2 # 2) cp file2 file1 # 3) vimdiff file1 file2 pattern="$1" file1="$2" file2="$3" #We don't want to have a case like this: # 's/a'b// #We need to change that to this: # 's/a'"'"'b// pattern=${pattern//\'/\'\"\'\"\'} if [ "$file2" = "" ]; then echo "Usage: prdiff " exit; fi sedcmd1="sed -e '$pattern' $file1" sedcmd2="sed -e '$pattern' $file2" echo $sedcmd1 echo $sedcmd2 changed=`diff <(eval $sedcmd1) <(eval $sedcmd2)` if [ "$changed" != "" ]; then clear; diff <(eval $sedcmd1) <(eval $sedcmd2) PS3="Action: " select action in "cp $file1 $file2" "cp $file2 $file1" "vimdiff $file1 $file2"; do if [ "$action" != "" ]; then $action; break; fi; done; fi;