Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
The Bash for Loop, the First Step in Automation on Linux (ma.ttias.be)
9 points by Mojah on July 6, 2016 | hide | past | favorite | 1 comment


  $ for file in $(ls); do echo $file; done
Please don't do this. I understand why it was put there, but don't. There are other examples of this construct, and most of them actually make sense.

People reading the article are not shell experts and don't know that in this particular case it's extremely bad idea to use `ls` (shell wildcard is the proper way here), so don't give them such example. This statement should be burned with fire.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: