If I use bash
's brace expansion I get a list
echo item={one,two,three}
item=one item=two item=three
Assuming I am in a directory with files/folders that would match a wildcard, is there any way to have an expansion that matches these files/folders?
ls
blue green red
echo item=* # Obviously not
item=*
echo item={} # Maybe? ...but no
item={}
In my example I would like the expansion to be item=blue item=green item=red
The best I've got so is code like this
items=()
for dirent in *; do items+=("item=$dirent"); done
echo "${items[@]}"
item=blue item=green item=red
printf 'item=%s ' *
? – terdon Jun 15 '20 at 09:25rsync --exclude...
) – Chris Davies Jun 15 '20 at 09:36eval
(yes, I know, "evil eval") - but in light of the answers posted here, it is probably a lot less helpful than I originally thought ... – AdminBee Jun 15 '20 at 10:15