linux - How do I use sed to change my configuration files, with flexible keys and values? -
i want search configuration file expression: "central.database". want change setting associated "central.database" "sqltest". the layout of config file initially: central.database = sqlfirsttest this want after sed replacement: central.database = sqltest i doing in bash script, suggestions, recommendations or alternative solutions welcome! (actually both central.database , sqltest come bash variables here.) my current code (third attempt): sshretvalue=$(ssh -p "35903" -i $home/sshids/idrsa-1.old ${1} <<eof sed -i "s/^\($central_db_name\s*=\s*\).*\$/\1$central_db_value/" /home/testing.txt; echo $? eof ) error message: pseudo-terminal not allocated because stdin not terminal. sed: -e expression #1, char 58: unknown option `s' -bash: line 3: eof: command not found here's example expression: sed -i 's/^\(central\.database\s*=\s*\).*$/\1sqltest/' file.cfg if want ...