When you use brace expansion in bash, something like
echo a b c
Is there a way to expand it to 3 separate commands, one for each expansion, instead?
echo a echo b echo c
Is this just a "because I wanna know" question, or is there a real use case for it? We could go through some gymnastics to get it done:
But I'd hunt down anyone that was putting in these kinds of obfuscatory commands into our system scripts.
Why not go for clarity instead:
You could even go whole-hog and put in a couple of newlines and indent it a bit so that you'd always be able to understand what you were trying to do.
Based on Mark Mann's selected answer, I was able to further derive this example, which works great:
What that is showing, is when you are using multiple occurrences of brace expansion within a line, Mark's original example would have printed every variation individually. Instead, I wanted to use his answer to move/rename multiple files. To ensure that the output matched the format that
As the above output appeared as expected, I was then able to run the following command:
Many thanks to Mark for his original answer. Please up-vote his answer if you like what his answer allowed me to do :-)