A kludgy way to do both parameters at once is
sed -i 's/^(\w*[td]_max_\w*size\s*=\s*).M/\1200M/' filename(s)
First of all, according to this List of php.ini directives,
there are only three keywords that contain
_max_ and end with
Note that the letter immediately before the
is different in each case:
so, by searching for
[td]_max_, we can eliminate the first one.
The command in detail:
^ of course constrains the regular expression
to match occurrences at the beginning of the line.
If you want to match strings that are not at the beginning of the line,
Note: unless you add something to specify otherwise,
this will cause the command to change lines that are commented out,
which might be confusing.
\(…\) identifies a group of characters.
We will use it to match everything up to
(but not including) the parameter value (i.e., the number after the
- any number of “word” (alphanumeric) characters,
t or a
- any number (possibly zero) of word characters, and
\s*=\s* matches any number of space characters (regular space or tab),
=, and any number of space characters again.
(You don’t need to say
This is the end of the group, marked by
- As you know,
.M matches any character followed by
(You’re using this already.)
\1200M looks confusing, but it’s just
\1, which replaces the characters in the
\(…\) group with themselves,
- followed by
200M, which is what you want to replace
nM number with.
You don’t need the
unless you expect to match multiple strings on the same line
(which is impossible if you anchor the regular expression
to the beginning of the line with
filename(s) with your
or any other filename or list of filenames.
Before doing the above, you should run
sed -n 's/^(\w*[td]_max_\w*size\s*=\s*).M/\1200M/p' filename(s)
which will show what the first command will do.