create array from var or file by delimeter
This commit is contained in:
parent
0384404c6e
commit
cc51aa469a
15
gaboshlib/g_array.sh
Normal file
15
gaboshlib/g_array.sh
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
function g_array {
|
||||||
|
local g_filename=$1
|
||||||
|
local g_arrayname=$2
|
||||||
|
local g_delimeter=$3
|
||||||
|
|
||||||
|
[ -n "$g_delimeter" ] && g_delimeter="-d${g_delimeter}"
|
||||||
|
if [ -f "$g_filename" ]
|
||||||
|
then
|
||||||
|
mapfile $g_delimeter -tn 0 $g_arrayname < "$g_filename"
|
||||||
|
else
|
||||||
|
mapfile $g_delimeter -tn 0 $g_arrayname <<< "$g_filename"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user