And*_*son 4 html bash shell shell-script macos
我想对位于文件夹和子文件夹中的大量文件运行 HTML Tidy。我可以在终端中使用以下命令在单个文件上运行它:
tidy -f errors.txt -m -utf8 -i sample.html
Run Code Online (Sandbox Code Playgroud)
但是我怎样才能运行它指定一个根文件夹并让它遍历那里的每个 html 文件,然后在每个子文件夹上做同样的事情?
使用find
.
find /path/to/folder -type f -name "*.html" -exec tidy -f errors.txt -m -utf8 -i {} \;
Run Code Online (Sandbox Code Playgroud)
这将在指定文件夹中的tidy
所有.html
文件上运行:
-type f
匹配所有文件(而不是文件夹、符号链接等)-name "*.html"
匹配所有带.html
扩展名的文件-exec tidy -f errors.txt -m -utf8 -i {} \;
运行指定的tidy
命令行,并在{}
. \;
是find
终止此命令所必需的。 归档时间: |
|
查看次数: |
1403 次 |
最近记录: |