(IFS=';'; mkdir $(locale mon))
locale mon
prints the names of months in the current locale, for example:
January;February;March;April;May;June;July;August;September;October;November;December
mkdir
creates directories specified as command line arguments.
$(...)
performs Command Substitution, which means that the output of the command ...
replaces the $(...)
expression. For example mkdir $(echo a b)
would become mkdir a b
and would create directories a
and b
.
To create directories for each month, we cannot simply use mkdir $(locale mon)
, because the output of locale mon
is not January February ...
but January;February;...
.
With IFS=';'
we tell the shell to use ;
as the field separator instead of the default.
We wrapped the entire command inside (...)
, which makes it a sub-shell. This means that changes to variables inside (...)
will not be visible outside the sub-shell. We did this because we only want to override the value of IFS
for this single operation, we want to keep the default value in the current shell.