I agree but I don't know much bash/shell scripting so I'm using what I know.
Also shell scripting is not very flexible.In particular,what you wrote there
in brackets "do whatever with $size here" will probably not be accomlished
very easily using shell scripting.