linux - 如何结合 echo 和查找?

标签 linux bash

当我执行以下操作时,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/

相关文章:

linux - 无法从不同的机器访问 weblogic 控制台

linux - 从 bash 中的一行读取表格数据

c++ - 内联函数调用错误

linux - 在新的 Linux 服务器上恢复 postgresql 安装

linux - Bash - 将命令行参数保存到输出文件中

linux - 从脚本获取要安装的软件包列表?

linux - 你如何管理服务器的根密码

bash - 嵌套的 Herodoc 操作顺序

bash - sed 仅更改文件中的字符串一次

bash - 紧急覆盖 bash 中损坏的命令完成?