0

In bash, I can do this:

for name in sqls/*.{schema,migration}.sql; do
    echo $name; # some operation on the file name
done

It would output something like this:

sqls/0001.schema.sql
sqls/0002.schema.sql
sqls/0003.migration.sql
sqls/0004.schema.sql
sqls/0006.schema.sql
sqls/0007.schema.sql

However, if I put the same loop into a Makefile:

names:
    for name in sqls/*.{schema,migration}.sql; do echo $name; done

The output become:

sqls/*.{schema,migration}.sql

How can I do the same thing in a Makefile?

  • 3
    Could you edit your question to show exactly what you tried in your Makefile? – Stephen Kitt Feb 23 '17 at 9:38
2

You need to realize that the {...} is a bash construct whilst Makefiles generally launch the sh which does not support the brace expansion feature.

However all's not lost; if you are with GNU Make then you can tell Make to use bash by putting this little line SHELL := bash at the very top of your Makefile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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