当我执行以下操作时,find
会覆盖 index.html
,我希望它只会附加其结果。
echo "<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head></body>" > index.html
find . -name "*.html" -exec echo "<a href=\"{}\">{}</a><br/>" \; >> index.html
假设找到所有 html 文件并为它们创建索引。
有没有人知道如何做到这一点,最好不使用临时文件?
最佳答案
问题出在你的 echo 线上, echo 线应该是:
echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head></body>' > index.html
您的文本和 echo 命令边界中也有 "
。
关于linux - 如何结合 echo 和查找?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8787267/