Skip to content
Vidar Holen edited this page Oct 20, 2022 · 1 revision

Use spaces, not commas, to separate loop elements.

Problematic code:

for f in foo,bar,baz
do
  echo "$f"
done

Correct code:

for f in foo bar baz
do
  echo "$f"
done

Rationale:

ShellCheck found a for loop where the items appeared to be delimited by commas. These will be treated as literal commas. Use spaces instead.

Exceptions:

None

Related resources:

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
Clone this wiki locally