Created
December 7, 2018 07:44
-
-
Save ljjjustin/265a0056aecef82f9078db280872bd82 to your computer and use it in GitHub Desktop.
join string in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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