#!/bin/bash

# Brace expansions are a mechanism to specify string patterns.
# General form: preamble{s1,s2,...sn}postscript
# where each si can also be a brace.
# Ranges can be specified with the notation: {x..y}
# Examples:

echo b{ed,olt,ar}s
ls *.{c,h,o}
echo {1..5}
echo {q..w}
echo b{ar{d,n,k},ed}s

# Example: enumerate all 'profile' files for root and all users under /home
# Note: when you combine globs and braces, brace expansion happens _before_
# filename expansion.
echo {/home/*,/root}/.*profile

# Example: create 20 files with names from 00.txt, 01.txt, ..., 19.txt
touch {0,1}{0..9}.txt

# Fun fact: brace expansion allows ranges counting backwards.
# Use with caution for non-trivial ranges as it depends on locale
# variables.
echo {9..0}
echo {f..a}

