我正在使用 sed 在 php 文件中查找配置指令。从本质上讲,我需要设置字符串database_name_here,username_here并password_here与在config-sample.php相应的值(和文件重命名为config.php文件)。我当前的解决方案使用 sed 3 次,将输出重定向到临时文件。
sed -e 's/database_name_here/foo/g' config-sample.php > /tmp/config.1
sed -e 's/username_here/bar/g' /tmp/config.1 > /tmp/config.2
sed -e 's/password_here/bat/g' /tmp/config.2 > config.php
Run Code Online (Sandbox Code Playgroud)
我想知道如何在不必创建两个临时文件的情况下获得相同的结果?
sed ×1