create array from var or file by delimeter

This commit is contained in:
olli 2024-04-24 15:08:09 +02:00
parent 0384404c6e
commit cc51aa469a

15
gaboshlib/g_array.sh Normal file
View 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
}