Skip to content

Commit d1291d8

Browse files
committed
split and join string added
1 parent 37bd18e commit d1291d8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

join_string.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!usr/bin/shell
2+
3+
function join () {
4+
local sep=$1
5+
shift
6+
builtin echo "$1$(shift ; for x do builtin echo -n "$sep$x"; done)";
7+
}
8+

split_string.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!usr/bin/shell
2+
3+
function split () {
4+
local IFS="$1"
5+
builtin echo $(for x in $2; do builtin echo -n "$x "; done);
6+
}
7+

0 commit comments

Comments
 (0)