The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 02-09-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,944
Code:
#!/bin/sh

FILE="xyzddddyymm.txt"

SIZES=( $(stat "--printf=\t%s" "${FILE}" "../${FILE}") )

if [[ "${SIZES[0]}" -gt "${SIZES[1]}" ]]
then
        echo "${FILE} > ../${FILE} by $((SIZES[0]-SIZES[1])) bytes"
elif [[ "${SIZES[1]}" -gt "${SIZES[0]}" ]]
then
        echo "../${FILE} > ${FILE} by $((SIZES[1]-SIZES[0])) bytes"
else
        echo "${FILE} and ../${FILE} are the same size"
fi