#!/bin/sh # Utility to compare two directories and say which has more files. # Basic idea: # Run numfiles on the first directory and remember count # Run numfiles on the second directory and remember count # Compare the sizes # Report the larger one if [ $# -lt 2 ] then echo "Insufficient arguments!" else if [ $# -gt 2 ] then echo "Too many arguments!" else SIZE1=`cd $1 ; /home/dsl/carey/classes/CPSC457/2010/ass1/numfiles` SIZE2=`cd $2 ; /home/dsl/carey/classes/CPSC457/2010/ass1/numfiles` if [ $SIZE1 -gt $SIZE2 ] then echo "Directory $1 has more files ($SIZE1 vs $SIZE2)" else if [ $SIZE2 -gt $SIZE1 ] then echo "Directory $2 has more files ($SIZE2 vs $SIZE1)" else echo "Directories $1 and $2 have the same number of files ($SIZE1)!" fi fi fi fi