Unable to use sed to customize buffer size in mariadb Dockerfile
Just don't escape the spaces like you do:
- spaces don't need escaping
- escaping with
\\
inside simple quotes actually create a\
char. No wonder why your regex doesn't work.
That works:
sed -i 's/innodb_buffer_pool_size = 256M/innodb_buffer_pool_size = 512M/g' /etc/mysql/my.cnf
- if you really have to escape something, that will be only because of regex, not the shell, because you have used simple quotes and the shell does not interpret the contents
- you don't need the
-r, --regexp-extended
switch for this particular example. regexp extended includes stuff like forward lookup, ... not needed here.
Improvement: use group to recall the matched value. Less maintenance if you have to change the parameter name
sed -i 's/\(innodb_buffer_pool_size\) = 256M/\1 = 512M/g' /etc/mysql/my.cnf
or match several parameter names
sed -i 's/\(innodb_buffer_pool_size\|some_other_param\) = 256M/\1 = 512M/g' /etc/mysql/my.cnf