Instantly share code, notes, and snippets.

What would you like to do?
Bash function to set or append to a Java settings file.
function set_or_append_java_config() {
local FILE=$1
local KEY=$2
local VALUE=$3
if grep -q "^${KEY}=" "${FILE}"; then
sed -i -e "s#^\\(${KEY}=\\).*"'$'"#\\1${VALUE}#" "${FILE}"
echo "${KEY}=${VALUE}" >> "${FILE}"

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment