#!/bin/bash # # Syntax: mdiff file1 [file2 ...] dir # # Purpose: Performs diff of file1, file2, ... against dir. # The -h flag shows the help info for this command. # # Note: You may have to include a line like # alias mdiff=~/your_bin_dir/mdiff # in your login files (e.g., .bashrc) in order to be able to use # this command. # Created: May 15, 2007 by Bart De Schutter # Last revised: Oct 21, 2008 by Bart De Schutter # # See http://www.deschutter.info/util/scripts.html for the latest version of # this script. # Status: public # Category: files # # Process options. # if [ $# -ge 1 -a "$1" = "-h" ]; then sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi if [ $# -lt 2 ]; then echo >&2 echo >&2 "ERROR: ${0##*/} requires at least 2 input arguments." echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi if [ -n "$(type -p less)" ] then less_command="\less -E -X -M -i -Q" else less_command="\more" fi # # Perform diff. # declare -a list list=("$@") idx=$# let idx-=1 dir=${list[$idx]} (for fil in "${list[@]:0:$idx}" do echo "diff $fil $dir" diff "$fil" "$dir" done) | eval $less_command