Yes, there is a better way to do what you need. There is a glob or readdir for starters.
Regarding the "standard practice", you will see a lot of this in the land of PHP. If the developer does not know PHP a huge code base very well, but knows the shell, they will eventually use exec and backticks (``) everywhere to do their job. This is standard practice that some percent of PHP developers hate, and another percent cannot live without. Get used to it.
source share