Skip to content

Instantly share code, notes, and snippets.

@ljjjustin
Created December 7, 2018 07:44
Show Gist options
  • Save ljjjustin/265a0056aecef82f9078db280872bd82 to your computer and use it in GitHub Desktop.
Save ljjjustin/265a0056aecef82f9078db280872bd82 to your computer and use it in GitHub Desktop.
join string in bash
#!/bin/bash
function join {
local IFS="$1"; shift; echo "$*";
}
arr=( 1 a 2 b c d e 3 )
result=$(join , ${arr[@]})
echo $result
## 1,a,2,b,c,d,e,3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment