Search code examples
bashbrace-expansion

bash's brace-expansion didn't work


i have a simple problem with bash's brace expansion:

#!/bin/bash  
PICS="{x1,x2,x3}.jpg {y1,y2}.png"    
for i in $PICS  
do  
  echo $i  
done

but the result is:
{x1,x2,x3}.jpg
{y1,y2}.png
But i want the result is: x1.jpg x2.jpg x3.jpg y1.png y2.png
what should i do ?


Solution

  • The straightforward way is

    #!/bin/bash  
    
    for i in {x1,x2,x3}.jpg {y1,y2}.png; do
      echo $i  
    done