#!/bin/sh # Utility to compare two files and say which one is larger. # Basic idea: # Stat the first file and remember its size # Stat the second file and remember its size # 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=`stat -t $1 | awk '{print $2}'` SIZE2=`stat -t $2 | awk '{print $2}'` if [ $SIZE1 -gt $SIZE2 ] then echo "File $1 is larger" else if [ $SIZE2 -gt $SIZE1 ] then echo "File $2 is larger" else echo "Files $1 and $2 are exactly the same size!" fi fi fi fi