For example, I want to rename a file abc
to bd
.
Why do the two brace expansions seem not to work?
Consider the following example.
$ touch abc
$ mv {a,}b{c,d}
mv: target `bd' is not a directory
How shall I make brace expansion work?
bashshell
For example, I want to rename a file abc
to bd
.
Why do the two brace expansions seem not to work?
Consider the following example.
$ touch abc
$ mv {a,}b{c,d}
mv: target `bd' is not a directory
How shall I make brace expansion work?
Best Answer
Two brace expansions do work, they just don't work the way you want them to:
They are expanded separately - effectively the first one is expanded, leaving you with
mv ab{c,d} b{c,d}
and then the second is expanded, leaving you withmv abc abd bc bd
.