Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Sed匹配/复制,然后放入posix shell中_Android_Linux_Shell_Sed_Posix - Fatal编程技术网

Android Sed匹配/复制,然后放入posix shell中

Android Sed匹配/复制,然后放入posix shell中,android,linux,shell,sed,posix,Android,Linux,Shell,Sed,Posix,因此,我尝试使用sed来查找下面每个变量的{和}之间匹配的所有代码,但是我想排除包含有#(在该行的任何部分中存在)的任何行的搜索。然后,我希望sed脚本将匹配的行复制到预期输出的“libraries{”下,然后在复制时在每个匹配的第一行副本的名称末尾添加一个# 查找匹配项/副本的原始代码: bundle { path /system/lib/soundfx/libbundlewrapper.so } #positive { #path /system/lib/soundf

因此,我尝试使用sed来查找下面每个变量的{和}之间匹配的所有代码,但是我想排除包含有#(在该行的任何部分中存在)的任何行的搜索。然后,我希望sed脚本将匹配的行复制到预期输出的“libraries{”下,然后在复制时在每个匹配的第一行副本的名称末尾添加一个#

查找匹配项/副本的原始代码:

  bundle {
    path /system/lib/soundfx/libbundlewrapper.so
  }
  #positive {
  #path /system/lib/soundfx/libpositive.so
  #}
  reverb {
    path /system/lib/soundfx/libreverbwrapper.so
  }
  jamesdsp {
    library jdsp
    uuid f27317f4-c984-4de6-9a90-545759495bf2
  }
  sa3d {
    library proxy
    uuid  1c91fca0-664a-11e4-b8c2-0002a5d5c51b
      libsw {
        library myspace
        uuid 3462a6e0-655a-11e4-8b67-0002a5d5c51b
      }
      libhw {
        library offload
        uuid  c7a84e61-eebe-4fcc-bc53-efcb841b4625
      }
  }
  #downmix {
    #library downmix
    #uuid 93f04452-e4fe-41cc-91f9-e475b6d1d69f
  #}
 visualizer {
    library visualizer
    uuid d069d9e0-8329-11df-9168-0002a5d5c51b
  }
预期产出:

libraries {
  bundle {#
    path /system/lib/soundfx/libbundlewrapper.so
  }
  reverb {#
    path /system/lib/soundfx/libreverbwrapper.so
  }
  proxy {
    path /system/lib/soundfx/libeffectproxy.so
  }
  jdsp {
    path /system/lib/soundfx/libjamesdsp.so
  }
 effects {
      jamesdsp {#
        library jdsp
        uuid f27317f4-c984-4de6-9a90-545759495bf2
      }
      sa3d {#
        library proxy
        uuid  1c91fca0-664a-11e4-b8c2-0002a5d5c51b
          libsw {
            library myspace
            uuid 3462a6e0-655a-11e4-8b67-0002a5d5c51b
          }
          libhw {
            library offload
            uuid  c7a84e61-eebe-4fcc-bc53-efcb841b4625
          }
      }
     visualizer {#
        library visualizer
        uuid d069d9e0-8329-11df-9168-0002a5d5c51b
      }
      dax {
        library dax
        uuid 9d4921da-8225-4f29-aefa-6e6f69726861
      }
然后我想在下面做同样的事情,但它更复杂,因为我还需要它来匹配和复制下面两个(它们都有“library”和“uuid”,但只有一些有硬件和软件)

匹配/复制的原始代码:

  bundle {
    path /system/lib/soundfx/libbundlewrapper.so
  }
  #positive {
  #path /system/lib/soundfx/libpositive.so
  #}
  reverb {
    path /system/lib/soundfx/libreverbwrapper.so
  }
  jamesdsp {
    library jdsp
    uuid f27317f4-c984-4de6-9a90-545759495bf2
  }
  sa3d {
    library proxy
    uuid  1c91fca0-664a-11e4-b8c2-0002a5d5c51b
      libsw {
        library myspace
        uuid 3462a6e0-655a-11e4-8b67-0002a5d5c51b
      }
      libhw {
        library offload
        uuid  c7a84e61-eebe-4fcc-bc53-efcb841b4625
      }
  }
  #downmix {
    #library downmix
    #uuid 93f04452-e4fe-41cc-91f9-e475b6d1d69f
  #}
 visualizer {
    library visualizer
    uuid d069d9e0-8329-11df-9168-0002a5d5c51b
  }
预期产出:

libraries {
  bundle {#
    path /system/lib/soundfx/libbundlewrapper.so
  }
  reverb {#
    path /system/lib/soundfx/libreverbwrapper.so
  }
  proxy {
    path /system/lib/soundfx/libeffectproxy.so
  }
  jdsp {
    path /system/lib/soundfx/libjamesdsp.so
  }
 effects {
      jamesdsp {#
        library jdsp
        uuid f27317f4-c984-4de6-9a90-545759495bf2
      }
      sa3d {#
        library proxy
        uuid  1c91fca0-664a-11e4-b8c2-0002a5d5c51b
          libsw {
            library myspace
            uuid 3462a6e0-655a-11e4-8b67-0002a5d5c51b
          }
          libhw {
            library offload
            uuid  c7a84e61-eebe-4fcc-bc53-efcb841b4625
          }
      }
     visualizer {#
        library visualizer
        uuid d069d9e0-8329-11df-9168-0002a5d5c51b
      }
      dax {
        library dax
        uuid 9d4921da-8225-4f29-aefa-6e6f69726861
      }

请记住,上面的代码需要放在“effects{”下。您的源文件具有Tcl语法,因此,如果我们将它们作为Tcl代码执行(使用适当的“unknown procedure”处理程序),我们就可以了。我有您的第一个示例“file1.dat”,第二个示例“file2.dat”

然后


它没有给出您想要的缩进。这是一个交易破坏者吗?

第一个示例中的
proxy
jdsp
是如何出现的?我将在Android的posix shell中尝试这一点。有没有办法保持缩进?这就是为什么我使用sed,这不是我首选的方法。
effects {
jamesdsp {#
    library jdsp
    uuid f27317f4-c984-4de6-9a90-545759495bf2
  }
sa3d {#
    library proxy
    uuid  1c91fca0-664a-11e4-b8c2-0002a5d5c51b
      libsw {
        library myspace
        uuid 3462a6e0-655a-11e4-8b67-0002a5d5c51b
      }
      libhw {
        library offload
        uuid  c7a84e61-eebe-4fcc-bc53-efcb841b4625
      }
  }
visualizer {#
    library visualizer
    uuid d069d9e0-8329-11df-9168-0002a5d5c51b
  }
      dax {
        library dax
        uuid 9d4921da-8225-4f29-aefa-6e6f69726861
      }