I’m making replacments in PHP file and I need to change the language variable with sed. Here my WORKING code:
sed -i '' -e "s/\$config\['language'\] = \"english\";/\$config['language'] = '$LANGUAGE';/" Sources/$APP/application/config/config.php
This is not working to match any language set:
sed -i '' -e "s/\$config\['language'\] = \"*\";/\$config['language'] = '$LANGUAGE';/" Sources/$APP/application/config/config.php
What’s wrong?
In
sed, the asterisk (*) character denotes “repeat the previous thing 0 or more times.” This is in contrast to a shell, where it expands to anything. What you want to do is shove a.(which means “anything”), right before the asterisk, like so:That will then tell your program “repeat any character (
.) any number of times (*)”.