Expansions are a great tool in bash and there are a lot of applications as well as expantion types, from bash documentaion:

Expansion is performed on the command line after it has been split into tokens. There are seven kinds of expansion performed:

  1. brace expansion
  2. tilde expansion
  3. parameter and variable expansion
  4. command substitution
  5. arithmetic expansion
  6. word splitting
  7. filename expantion

The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; and filename expansion.

Here are some useful command to use when you need to automate repetitive tasks and avoid doing them amnually:

Folders, files and lists!

This will create one folder for each alphabeth’s letter!

for i in {a..z}; do mkdir $i; done

Create multiple subfolders in one go:

mkdir -p /home/users/{doug,paty,andy,mike,diana}

Or create multiple files:

touch /tmp/{1..10}.log

List all the years where FIFA’s World Cup of football has taken place? easy:

echo {1930..2009..4}

Notice the third value in the last secuence, that’s a step increment and it also can be a negative value! You’ll get the same result with:

echo {2006..1930..-4}

Thanks for reading!