SED(Linux)递归问题 [英] SED (linux) issue with recursive

查看:101
本文介绍了SED(Linux)递归问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用 $ _ SERVER ['PHP_SELF'] 替换字符串 $ PHP_SELF code> php 文件。我已经运行了此命令,但是它只是删除了字符串并什么都不替换:

I'm trying to replace the string $PHP_SELF by $_SERVER['PHP_SELF'] in all php files. I've ran this command, but it simply remove the string and replace by nothing:

cd /home/rg/public_html && find . -type f -print0 | xargs -0 perl -i.php -pe "s/\\\$PHP_SELF/\$_SERVER['PHP_SELF']/g"

有什么想法吗?

推荐答案

只需使用gnu sed / grep / xargs ,例如:

Just use gnu sed/grep/xargs, such as:

$ cd /home/rg/publick_html
$ find . | grep "[.]php$" | xargs sed -e 's/\$PHP_SELF/\$_SERVER\['PHP_SELF'\]/g'  -i

还:

find . -type f -name "*.php" | xargs sed -e 's/\$PHP_SELF/\$_SERVER\['PHP_SELF'\]/g'  -i

感谢@Utopik

祝你好运〜

这篇关于SED(Linux)递归问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆