gpt4 book ai didi

bash - 带有 sed 的嵌入式 linux 命令

转载 作者:行者123 更新时间:2023-12-04 04:51:16 25 4
gpt4 key购买 nike

我是 shell 脚本的新手。我正在寻找一个脚本来帮助我实现以下要求:

  • 我有 java threaddump 文件和一个脚本来分析它。分析脚本给了我大约 15 行的输出。
  • 我有一个 html 页面模板。
  • 我想将分析脚本输出附加到 html 页面的第 15 行,将日期和主机名附加到第 4 行。

  • 我用 sed 命令尝试了几个选项,但未能在 sed 命令中插入其他 linux 命令。
    #sed -i '15i 'hostname'' test.html
    #sed -i '15i "`hostname`"' test.html
    #sed -i '15i "hostname"' test.html
    #sed -i '15i `hostname`' test.html --> These options i tried but no luck.

    请帮忙

    最佳答案

    你应该从 shell 中使用它

    sed -i "15i `hostname`" test.html

    ""将评估里面的文本,`` 将文本作为脚本执行并粘贴到其输出中

    关于bash - 带有 sed 的嵌入式 linux 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17402704/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com