Alex Rivera | Logout

Brace expansion with a Bash variable - {0..$foo}

Asked 2012-02-18T00:56:39.767
16
WEEKS_TO_SAVE=4
mkdir -p weekly.{0..$WEEKS_TO_SAVE}

gives me a folder called weekly.{0..4}

Is there a secret to curly brace expansion while creating folders I'm missing?

Edit
Report

1 Answer

11

Another way of doing it without eval and calling mkdir only once:

WEEKS_TO_SAVE=4
mkdir -p $(seq -f "weekly.%.0f" 0 $WEEKS_TO_SAVE)
answered 2012-02-18T11:45:31.527

Your Answer