Here I respond to a request for help I received last week and I have not until now had time to respond.
I am asked for advice on a bash script that processes a set of directories and creates other temporarily in / tmp.
Without going into details of the case, to automatically generate lists or arrays of directory there is solace in the coal expansion.
This is a special mechanism with which to bash you can generate arbitrary lists of names of files or directories.
In this sense it is similar to pathname expansion, although the latter is bound to the existence of files and / or the directory in question, while coal expansion this limit is not expected.
The syntax is very simple expansion of the fire and expected to be listed in curly brackets string will be replaced in the same position within the main string, thereby generating variants that we need. As always, an example is worth a thousand explanations:
to {b, c, d} and
expands to:
- abe
- ace
- Hades
The brace expansion has priority over all other expansion and must contain the opening and closing braces, and at least one separator (comma).
Here is the missing line of code to the script above:
/bin/mkdir /tmp/{dir_main,dir_all,dir_tmp_1,dir_tmp_2,dir_tmp_3}







