i want to write a script to compare the file size of the files in the current dir with the files in the previous directory.
the files name will be same, but the filename format will be as xyzddddyymm.txt. the files will arrive with the month end date(i want to compare the monthly files). so can anybody help me to find a solution for this.
#!/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