Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BASH: Parse .properties file into two saperate arrays.
#!/bin/bash
file=<filename.format>
declare -A valueArray
declare -a keyArray
while IFS='=' read -r key value
do
key=($(echo $key | tr '.' '_'))
if [[ " ${keyArray[*]} " == *" ${key} "* ]]; then
eval ${key}=\${value}
#echo "arr contains d"
valueArray["${key}"]="$value"
fi
done < "$file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment