Implement a formatted shell script output | Amazon Interview Question