Background: Multiple items in the code of the log printing level unified replacement, if the file size, the number of many, to do it obviously powerless, through the script, this replacement sed the most suitable.
Title:
I:
I want to put: Log_threshold =n;
To be replaced by: Log_threshold = 1;
I want to put: Show_debug_errors=anyword;
To be replaced by: Show_debug_errors=false;
Ii:
Error_reporting (e_all ^ e_notice);
Change:
Error_reporting (e_all ^ e_notice);
I): Log switch, error level modification:
First, the SED replacement method is as follows (this place is provided by the Scottjiang brothers, I played a little later:-)):
Sed "s/log_threshold =. *;$/log_threshold = 1;/g;s/show_debug_errors =. *;$/show_debug_errors = false;/g" index.php > I Ndex.php.new
MV Index.php.new index.php
Second, if you do not want to back up the direct replacement:
Sed-i "S/log_threshold =. *;$/log_threshold = 1;/g;s/show_debug_errors =. *;$/show_debug_errors = false;/g" index.php
The index.php of multiple projects should be unified with SED replacement:
Grep-rl "Log_threshold ="/|grep Index.php|xargs sed-i "s/log_threshold =. *;$/log_threshold = 1;/g;s/show_debug_error s =. *;$/show_debug_errors = false;/g "
II): SED implementation of the PHP code to a feature to comment on a line (such as: The project online do not want it to open error reporting to users):
If you want to:
Error_reporting (e_all ^ e_notice); Change:
Error_reporting (e_all ^ e_notice);
Sed substitution method:
Sed ' s/error_reporting///error_reporting/g './index.php
And: can also be combined with the above three implementation of bulk replacement to achieve multiple files containing the above string of the line to give comments off:
Grep-rl "error_reporting (e_all ^ e_notice);/|grep Index.php|xargs ' sed-i '
To replace the mysqldump from the long field from the border of 0:
Case: Mysqldump out of the line from the growth field, there will be a default value, and the extranet will need to start from the line, this SQL also needs to be replaced (http://www.111cn.net/)
Deo ' VALUES (1121,null, '
Replace with SED:
Sed-i "s/([0-9]*/0/g"/tmp/result.sql
After the replacement, for 0, when the line is inserted, the default growth from the online, rather than the above 1121:
_video ' VALUES (0,null, ' 2 '
Sed-i ' s/([0-9]*,/0,/g ' //filename substitution (12122, ==> (0,