Globbing/pathname expansion with colon as separator Globbing/pathname expansion with colon as separator shell shell

Globbing/pathname expansion with colon as separator


Actually, I thought of a better solution: use a shell function.

function join() {    local IFS=$1    shift    echo "$*"}mystring=$(join ':' /var/lib/gems/*/bin)


This should do it for you:

dirs=(/var/lib/gems/*/bin)    # put filenames (dirnames) in an arraysaveIFS=$IFS IFS=':'          # set the Internal Field Separator to the desired delimiterdirs=("${dirs[*]}")           # convert the array to a scalar with the new delimiterIFS=$saveIFS                  # restore IFS


PATH="$(printf "%s:" /usr/*/bin)"PATH="${PATH%:}"