join in zsh
Unlike the join utility which make a join similar to SQL ones. Here is a function to make the same work as the join function in javascript, Perl or Python:
> join ';' 'hello world!' "I'm here!" "I'm happy"
hello world!;I'm here!;I'm happy
Here is a short solution:
function join { local res="" if (($#>0)); then local sep="$1" shift if (($#>0)); then res=$1 shift while (($#>0)); do res=$res$sep$1 shift done fi fi print $res }
Blogged with the Flock Browser
leave a comment