If you have a command that takes an argument with a value often you can do something like:
journalctl -u{rspamd,postfix}
# Expands to: journalctl -urspamd -upostfix
journalctl --unit={rspamd,postfix}
# Expands to: journalctl --unit=rspamd --unit=postfix
However some commands don't support arguments concatenated like that and require --unit rspamd --unit postfix. Is there a clean way to expand multiple values of these flag using brace expansion? Obviously the following doesn't work:
journalctl --unit {rspamd,postfix}
# Expands to: journalctl --unit rspamd postfix
As long as the additional arguments don't themselves contain whitespace, you can do something like
The parameter expansion uses the
zflag to perform word-splitting on the result of the parameter expansion. The brace expansion includes the space in the brace expansion because the expression following:-is not subject to word-splitting. As a result, the entire parameter expansion (which, yes, doesn't actually involve a parameter) produces 4 words:--unit,rspamd,--unit, andpostfix.