1

This question already has an answer here:

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

#!bin/sh
for file in *.{zip,jar}
do
echo $file
done

which gives the output:

*.{zip,jar}

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.

3

The following shellscript works for me

#!/bin/bash

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.