Created
December 27, 2017 20:41
-
-
Save marzvrover/f68445c7ed5fd3694a340e6a6c1d4997 to your computer and use it in GitHub Desktop.
Simple script to update variables in a file. Use with variables files where the pattern is key=value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
var_file_location="/usr/local/etc/php/php.ini" | |
declare -A values | |
values["upload_max_filesize"]="2M" | |
for key in "${!values[@]}" | |
do | |
grep -q "^$key" $var_file_location && \ | |
sed -i "s/^\($key\).*/\1=$(eval echo \${values[$key]})/" $var_file_location || \ | |
echo "$key=${values[$key]}" >> $var_file_location | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment