3 ms·
Brace expansion won't work if you need to make edits in multiple places.
by FreeFull 6y ago
Brace expansion won't work if you need to make edits in multiple places.
- kazinator 6y agoWell, it could work if we have a function to pick off the first and last combination from the Cartesian product, haha. We define: # print first and last argument fl() { local a=("$@"); printf "%s %s\n" "${a[0]}" "${a[${#a[@]} - 1]}" } Now: $ fl {a,b}--{c,d}--{foo,bar}--{x,y}--{m,n} a--c--foo--x--m b--d--bar--y--n We can use this using command substitution, or the old backticks: $ mv $(fl path/{from,to}/subdir/{foo,bar}.png) There we go; edits in multiple places.