Shell script for looping mechanism