Skip to content

Instantly share code, notes, and snippets.

@bradmartin333
Created June 26, 2025 20:02
Show Gist options
  • Save bradmartin333/d524ca4516ac0cc9a934de7ea9110c68 to your computer and use it in GitHub Desktop.
Save bradmartin333/d524ca4516ac0cc9a934de7ea9110c68 to your computer and use it in GitHub Desktop.
update file with jq
#!/bin/bash
# Check if an argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <bitrate>"
exit 1
fi
# Store the original settings.json
mv settings.json settings_orig.json
# Use jq with --arg to pass the first CLI argument ($1) as the bitrate
# This safely passes the shell variable into the jq expression.
jq --arg bitrate "$1" '.Rushes.Bitrate = ($bitrate | tonumber)' settings_orig.json > settings.json
# Remove the original settings file
rm settings_orig.json
echo "Bitrate updated to $1 in settings.json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment