The usage of 'ls' command to fetch list of files to be processed in shell scripts - especially in for-loops is totally unnecessary. You can achieve the same result by simply using shell-globbing (wild-card expansions), which leads to a more optimal script. In this video, you will learn how to do so - using a simple example.
...
https://www.youtube.com/watch?v=EiC_xYy_nsI