Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
Created December 1, 2017 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaytaylor/42a09cdc6297cef9a7aca42ab734a95d to your computer and use it in GitHub Desktop.
Save jaytaylor/42a09cdc6297cef9a7aca42ab734a95d to your computer and use it in GitHub Desktop.
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}"
else
echo "${KEY}=${VALUE}" >> "${FILE}"
fi
}
@jaytaylor
Copy link
Author

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