Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要替换短语 include('file.php') 的实例来读取 require('file.php') 我尝试使用以下脚本,但无济于事。是因为它有引号吗?还有什么原因?PS OSX 10.7.5
/usr/bin/perl -p -i -e "s/include('file.php')/require('file.php')/g" *.php
不,这是因为括号是元字符,它们进行分组。你需要用反斜杠转义它们。或者更简单,让perl我们用quotemeta函数(也\Q)来做:
perl
quotemeta
\Q
/usr/bin/perl -p -i -e "s/\Qinclude('file.php')/require('file.php')/g" *.php