|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
URGENT: how to compare the content of two directories in solaris
Hi,
I would like to compare the two directories in solaris. Any script i can use to archieve this purpose? Hopefully the script can find the different of these two direcotries and will scan the sub folder too. Many many Thanks! |
|
#2
|
|||
|
|||
|
Quote:
Start with reading "man diff". If you have troubles, write again. ![]() |
|
#3
|
|||
|
|||
|
Quote:
read man diff to state: diff is the wrong tool, but you get a link to dircmp not clear what you want compare. |
|
#4
|
|||
|
|||
|
I want to compare two directories to find out:
- new file - changed file - deleted file And then can display a summary after compare: Summary: New : 5 Changed: 3 Deleted : 1 Thanks |
|
#5
|
|||
|
|||
|
Quote:
Here you are: : usage () { echo "$0: call: $0 old_dir new_dir" >&2 exit 1 } # Check the arguments [ $# -eq 2 ] || usage [ -d $1 ] || usage [ -d $2 ] || usage # Store the directories OLDD=$1 NEWD=$2 # Contents of the old directory cd $OLDD find . >/tmp/cont_old # Contents of the new directory cd $NEWD find . >/tmp/cont_new # Determine what is only in the old directory comm -23 /tmp/cont_old /tmp/cont_new >/tmp/in_old # Determine what is only in the new directory comm -13 /tmp/cont_old /tmp/cont_new >/tmp/in_new # Determine what is in both directories comm -12 /tmp/cont_old /tmp/cont_new >/tmp/in_both # Evaluate the lists NEW=`cat /tmp/in_new | wc -l` DEL=`cat /tmp/in_old | wc -l` CHAN=0 while read APP; do # Do not test the subdirectories [ -d $APP ] && continue # Get rid of './' APP=${APP#./} # Compare the plain files diff $OLDD/$APP $NEWD/$APP 1>/dev/null 2>&1 || { CHAN=`expr $CHAN + 1` } done</tmp/in_both # Output echo "New:" $NEW echo "Changed:" $CHAN echo "Deleted:" $DEL I give you the fish, but you should learn to catch one yourself. To begnin with, you can study and modify my scritpt. It should remove the working files on end, give the possibility to show the differences, try set -xv to see the intermediate results... I have tested it under Solaris, but it should run on every Unix. Regards ![]() |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > URGENT: how to compare the content of two directories in solaris |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|