This question already has an answer here:

I am trying the following script for listing the archived files in my current directory.

for file in *.{zip,jar}
echo $file

which gives the output:


Why isn't shell expanding the braces?

marked as duplicate by muru bash Nov 7 '18 at 19:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


The following shellscript works for me


for file in *.{png,jpg}; do echo $file; done
  1. This brace expansion works in bash, but not in sh

  2. #!bin/sh lacks a slash, should be #!/bin/sh to work correctly

Not the answer you're looking for? Browse other questions tagged or ask your own question.