Reinstalling the uninstalled packages using a bash script to make things back to normal

I clearly don't see what going on. No output whatsoever. Here can't keep track of remaining packages to be reinstalled since I don't see anything. Help me see it.

This can be understood in many ways. As I understand your question, you want to debug your script, and your goal is to see what happens during script execution.

This can be achieved by invoking bash with the -x switch:

sudo /bin/bash -x ls.sh

From man bash:

-x Print commands and their arguments as they are executed.