Skip to content

Instantly share code, notes, and snippets.

@amazingandyyy
Created January 29, 2024 22:39
Show Gist options
  • Save amazingandyyy/39641e672b27a85952affff425009a4c to your computer and use it in GitHub Desktop.
Save amazingandyyy/39641e672b27a85952affff425009a4c to your computer and use it in GitHub Desktop.
merge_config_json() {
local src=$1
local target=$2
local temp_file
temp_file=$(mktemp)
if [[ -f "$target" ]]; then
jq -s '.[0] * .[1]' "$src" "$target" > "$temp_file" && mv "$temp_file" "$target"
else
# If target does not exist, override it with source
cp "$src" "$target"
fi
rm -f "$temp_file"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment