我想自动注释掉PHP文件中的代码块,如下所示:
原始块:
// Enable all errors
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(E_ALL);
带注释的新块:
/* For the production version, the following codelines are commented
out
// Enable all errors
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(E_ALL);
*/
所以我打算将这些行放在两个文件中,并使用 sed 自动执行替换。然而,在网上搜索后,我只找到Replace string with content of a file using sed和sed - Replace string with file content,这意味着要么只有源模式或目标模式在一个文件中,其余的在网上。但文件中没有两者的样本。
那么,如何进行更换呢?我应该使用 sed 还是 awk?