Wednesday, August 4, 2010

An useful shell script to use diff in a directory

Hi I just made this script to use diff in two directories, it fetch the files in the directories and diff them, if it finds a subdirectory it goes in and diff the files inside, I hope you use it and make it better.

You have to name the file and place it in your home, sorry this is my first script and I dont know how to use paths, there are 3 parameters.

To call the script there are 3 parameters:

sh original_directory copy_directory diff_files_firecory


sh my_project my_copy different_files


for i in $(ls $1)
    if [ -f "$1/$i" ];then
 diff $1/$i $2/$i > $filename
 filesize=$(wc -c < $filename)
        if [ $filesize = 0 ];then
            rm $filename
 mkdir $3/$i
 sh $HOME/ $1/$i $2/$i $3/$i