How to read a key-value pair file into an associative array when the value portion may have the delimiter in the value? So, split the line on the first occurrence of the delimiter, and store in an associative array.
Example KVP file contents:
key=value
key1=[SHA:]$value()%_&+=
I'd like to do something like
KVP_FILE="./file.properties"
declare -A keyvals
while read line; do
??
keyvals[$key]="$value"
done < $KVP_FILE
This is a broken code sample which loses the trailing = in the key1 from the file sample above.
while IFS=$'=' read key value; do
[[ $key = [#!]* ]] || [[ $key = "" ]] && continue;
keyvals[$key]=$(echo "$value" | sed 's/[\/&]/\\&/g')
done < $SFILE