wordpress 替换掉谷歌相关的资源实现国内访问加速

最近更新了wordpress的plugin却忘了替换googleapis,造成网页访问变慢,mark一下
// 查找 google 相关调用 grep -rn “googleapis.com" // 替换命令 sed -i
sed -i
是一个非常强大的文本处理命令,它用于在 Linux 和 Unix 系统中对文件进行查找和替换操作。sed
命令代表流编辑器(stream editor),它允许你对来自标准输入或一个或多个文件的文本进行过滤和变换。当配合 -i
选项时,sed
会直接修改文件,而不是将结果输出到标准输出。
基本用法
sed -i
的基本语法如下:
sed -i 's/原字符串/新字符串/' 文件名
备份修改前的文件:
sed -i
支持在修改文件之前创建一个备份,你只需要在 -i
后面加上备份文件的扩展名:
sed -i'.bak' 's/test/example/g' example.txt
替换相关谷歌服务的例子:
sed -i "s/fonts.googleapis.com/fonts.lug.ustc.edu.cn/g" `grep fonts.googleapis.com -rl /www/wp-content/` sed -i "s/ajax.googleapis.com/ajax.lug.ustc.edu.cn/g" `grep ajax.googleapis.com -rl /www/wp-content/` sed -i "s/www.gravatar.com/gravatar.lug.ustc.edu.cn/g" `grep www.gravatar.com -rl /www/wp-content/` sed -i "s/fonts.gstatic.com/fonts-gstatic.lug.ustc.edu.cn/g" `grep fonts.gstatic.com -rl /www/wp-content/`
2 Comments
软件工程师 只看Altium Designer的PCB和原理图 有好用的工具推荐吗
下载|6001