转换网站目录中的所有图像链接(在Mac上) [英] Convert all image links in a website directory (on mac)
问题描述
我的任务是获取网站文件的目录,包括html,css和非文本图像文件,并将所有图像路径从相对路径更改为通用cdn路径.这是在Mac上.
My task is to take a directory of website files, including html, css, and non-text image files, and change all image paths from relative paths to a universal cdn path. This is on a mac.
我的出发点是这样的:
sed -i '' 's/old_link/new_link/g' *
但是我希望它仅对css,html文件起作用,并通过任何子目录递归.
but I want it to act only on css,html files, and to recurse through any subdirectories.
谢谢
推荐答案
尝试使用find
.像这样的东西:
Try using find
. Soemthing like:
find . -name *css -exec sed -i '' 's/old_link/new_link/g' {} ';'
将在当前目录及其下找到所有的css文件,并将每个文件传递给sed. {}
代表查找到的每个文件的名称(和位置).不要在决赛中省略引号;
will find all the css files in your current directory and below it and pass each one to sed. The {}
stand in for the name (and location) of each file that find finds. Don't omit the quote marks around the final ;
然后重复html文件.
Then repeat for html files.
与往常一样,有关语法的更多信息,请咨询man或Google以获取查找文档.
As ever, for the finer points of syntax consult man, or google for the find documentation.
这篇关于转换网站目录中的所有图像链接(在Mac上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!