for each in bash, sh and zsh


I wrote about for each feature in bash, sh and zsh, I mean loop for a list. You know, there’s no for each statement in bash, sh or zsh.

for sh and bash

The following code works in sh and bash.

In sh and bash, space splits items. However, space doesn’t work as splitter in zsh.

bash

In zsh, generate list like the following code.

The zsh code is similar to LL like Ruby and PHP, etc.