My bash is not good, but it seems to do the trick and will compare files in two directories who's only difference is the path.
#!/bin/bash
#List the files that end with 'xml' in the final directory of $1 (you specify $1
#as the first arg on the command line)
#Note that when you list with a wild card *nix will list out the full path. If you know how to disable that #for ls, then you can use that instead, but I didn't see anything in the man pages. Therfore, strip it #out with a quick and dirty regex
ls /home/blah/jboss/server/all/$1/*xml > dir
orig_jboss="/home/blah/jboss-4.2.3.GA.20090611/server/all/$1/"
new_jboss="/home/blah/jboss/server/all/$1/"
#note the >>. If you don't put both it will only write the last one into the new file.
#>> will force an append
for file in `cat dir`; do echo ${file#/home*$1/} >> actual_dir ; done
for i in `cat actual_dir`; do diff $new_jboss$i $orig_jboss$i ; done
#If you don't do this and run the script a few times, you'll keep appending more
#things into 'actual_dir'
rm dir actual_dir
If everything is the same you shouldn't see any output. Otherwise you'll get a list of all the differences without having to do much by hand.
No comments:
Post a Comment