I'm using Ksh88 .
I've last day files in one directory and current month files in another directory , having the same naming convention.
Now i need to compare these folders size , if there is no change in these files then no action to be performed
else if there is a change then i need to call another script for ex: abc.sh
Now i tried this using zip -r command in the script, but though there is no difference in the file content in the 2 folders ,
the script is showing that the size is different .
#!/bin/ksh
bas_file="/etc/home"
zip -r zip_last.zip "$bas_file/Lst_Day"
zip -r zip_curr.zip "$bas_file/Cur_Day"
sze_last=$(ls -ltr zip_last.zip |awk '{ print $5 }')
sze_curr=$(ls -ltr zip_curr.zip |awk '{ print $5 }')
echo "$sze_last" # here size is 1456
echo "$sze_curr" # here size is 1365 though 2 files are equal
if [[ $sze_last == $sze_curr ]]
then
echo "Equal"
else
echo "Not Equal"
fi
What changes need to be done in the above script .
And suggest me the best way to compare files in folder .
Thank You
---------- Post updated at 01:33 PM ---------- Previous update was at 12:45 PM ----------
Could you please suggest me the best way to compare files in 2 directories.
I don't need the difference in 2 files after comparision just want to get the information that the files are equal or not .
I tried with CMP ,ZIP command , and waiting for your suggestions
Thanks