Awk Shell脚本:Grep一个文件中的值并将其放入另一个文件中

Awk Shell脚本:Grep一个文件中的值并将其放入另一个文件中,awk,grep,Awk,Grep,我有两个文件在两个不同的路径。我想将安装的版本从文件1复制到文件2 文件1:VersionInfo.Properties: Installed Version:13.9.0-9 Previous Version:13.8.0-2 文件2:Install.sh #!/bin/bash --- #some content is there ---- uninstall_and_install_rpm component 13.7.0-3 ----- ----

我有两个文件在两个不同的路径。我想将安装的版本从文件1复制到文件2

文件1:
VersionInfo.Properties

Installed Version:13.9.0-9
Previous Version:13.8.0-2
文件2:
Install.sh

  #!/bin/bash
    --- #some content is there
    ----
   uninstall_and_install_rpm component 13.7.0-3
   -----
    ------
  #!/bin/bash
    --- #some content is there
    ----
   uninstall_and_install_rpm component 13.9.0-9
   -----
    ------
所需输出:

文件2:
Install.sh

  #!/bin/bash
    --- #some content is there
    ----
   uninstall_and_install_rpm component 13.7.0-3
   -----
    ------
  #!/bin/bash
    --- #some content is there
    ----
   uninstall_and_install_rpm component 13.9.0-9
   -----
    ------

真可惜。你想分享一些细节吗?它只是打开文件Install.sh,但什么也不做。我怀疑在“/uninstall\u和\u install\u rpm/{$NF=ver}”这行附近,因为在
uninstall\u和\u install\u rpm组件13.9.0-9
之后还有一个词,我的代码根据您提供的示例文件工作。如果它们不符合实际情况,您必须编辑您的问题。它将打开文件install.sh并进行更新,但文件不会保存。它只是向我展示了上的更新版本screen@sravs448,这是你需要说的信息,而不是“它不起作用”。我已经更新了我的答案以适应您。@JP Lew:如果您对sed有任何想法,请您将其发布在这里,以便我可以尝试一下。