#!/bin/sh get_conf_sec() { sed -n "/\[$1\]/,/\[/ p" | sed '/]/ d; s/#.*//; /./ !d; s/ *= */=/; s/=\(.*\)/="\1"/' } cat $2 | get_conf_sec $1