How can I convert a string containing glob characters such as
/var/lib/gems/*/bin
into a colon-separated string of filenames (i.e. PATH com
This should do it for you:
dirs=(/var/lib/gems/*/bin) # put filenames (dirnames) in an array saveIFS=$IFS IFS=':' # set the Internal Field Separator to the desired delimiter dirs=("${dirs[*]}") # convert the array to a scalar with the new delimiter IFS=$saveIFS # restore IFS