Skip to content

Instantly share code, notes, and snippets.

@ephemerr
Last active November 24, 2017 06:11
Show Gist options
  • Save ephemerr/c31af6959187f2554ff52f9d227f2ef9 to your computer and use it in GitHub Desktop.
Save ephemerr/c31af6959187f2554ff52f9d227f2ef9 to your computer and use it in GitHub Desktop.
#!/bin/bash
function get_setting_value {
declare SECTION=$1
declare KEY=$2
sed -nr '/\['$SECTION\]'/,/\[.*\]/{/'$KEY'/s/(.*)=(.*)/\2/p}' "$INI_FILE"
}
function set_setting_value {
declare SECTION=$1
declare KEY=$2
declare VALUE=$3
sed -ri '/'$SECTION'/,/\[/ s/(\s*'$KEY'\s*=\s*).+/\1'$VALUE'/' "$INI_FILE"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment