blob: c4a098c30478968dbc1a05301a313de490ec6821 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
# Get specific value from ini file
# ini_get <file> <section> <key>
ini_get () {
awk -v section="^\\\\s*\\\\[$2\\\\]" -v key="^\\\\s*$3\\\\s*=\\\\s*" '{if ($0 ~ section) {ins=1} else if ($0 ~ "^\\s*\\[") {ins=0} else if (ins && $0 ~ key) {gsub(key, ""); print; exit 0} }' "$1"
}
# List all sections in ini file
# ini_sections <file>
ini_sections () {
awk '{if (match($0, "^\\s*\\[([^\\]]*)\\]", a)) {print a[1]}}' "$1"
}
|