ignore certain keys and make it more flawless

lektura
max.mehl 2018-06-08 16:42:53 +02:00
parent 547b08bfef
commit 26e4ce9903
No known key found for this signature in database
GPG Key ID: 2704E4AB371E2E92
1 changed files with 10 additions and 4 deletions

View File

@ -1,11 +1,14 @@
#!/bin/bash
# strings to ignore
ignore=("languageCode" "languageName")
while read line; do
# start of a new section?
if echo "${line}" | grep -Eq "^[\s]*\[.+?\]"; then
section=`echo "${line}" | grep -Eo "\[.+?\]" | sed -E "s|\[\|\]||g"`
section=`echo $section | sed -E "s|Languages\...\.||"`
section=`echo $section | sed -E -e "s|Languages\...\.||" -e "s|\.|_|g"`
if [[ "$newline" -eq "y" ]]; then
newline=n
else
@ -13,11 +16,14 @@ while read line; do
fi
elif echo "${line}" | grep -Eiq "^[\s]*[[:alnum:]]+?\s*="; then
key=`echo "${line}" | grep -Eio "^[\s]*[[:alnum:]]+?\s*=" | sed -E -e "s|\s||g" -e "s|=||"`
key="$section.$key"
key=`echo "${section}_${key}" | sed -E "s|^Languages_.._||"`
value=`echo "${line}" | sed -E "s|.*=\s*?(\".*\")|\1|"`
echo "[$key]"
echo "other= $value"
if [[ ! " ${ignore[@]} " =~ " ${key} " ]]; then # if key contains string
echo "[$key]"
echo "other= $value"
fi
elif echo "${line}" | grep -Eq "^\s*#"; then
echo
echo "$line"