Skip to main content
1 of 2
guest
  • 2.2k
  • 6
  • 11

There is the parameter expansion ${name:#pattern} (pattern can be empty), which will work on elements of an array:

$ a=('a' '' 'b' 'c')
$ echo ${(j/./)a:#}
a.b.c
$ # If the expansion is in double quotes, add the @ flag:
$ echo "${(@j/./)a:#}"
a.b.c

man 1 zshexpn:

${name:#pattern} If the pattern matches the value of name, then substitute the empty string; otherwise, just substitute the value of name. If name is an array the matching array elements are removed (use the (M) flag to remove the non-matched elements).

guest
  • 2.2k
  • 6
  • 11