I've searched a few places and didn't find one for my needs, basically here's the config:
name1 = value1;
name2= value2
name3 =value3 // comments
name4=value4 //empty line above and/or below
I need a shell script that reads the config file and parse all the name / value pairs with starting/trailing semicolons/spaces removed and comments as well as empty lines ignored.
I first tried
while read -r name value
do
echo "Content of $name is ${value//\"/}"
done < $1
I tried to trim name and value by:
"${var//+([[:space:]])/}"
but still not sure how to remove the semicolon and ignore the empty lines and comments?
< $1(which should properly be< "$1")with something like< <(sed -e '/^$/d' -e 's%[[:space:]]*//.*%%' -e 's/;$//' -e 's/[[:space:]]*=[[:space:]]*/ /' "$1")"parser", just change the comment identifiers to#, remove the spaces on either side of the=sign, and thensource config.fileinto your script... That would make a lot more sense...