android - Sed match/copy and then place in posix shell -
so i'm trying come sed find code matches below between { , } each variable below, want exclude search includes of lines have # (present in part of line). want sed script copy matched lines under "libraries {" of expected output , add # @ end of name of first line copies each match when copying.
original code find match/copy:
bundle { path /system/lib/soundfx/libbundlewrapper.so } #positive { #path /system/lib/soundfx/libpositive.so #} reverb { path /system/lib/soundfx/libreverbwrapper.so } expected output:
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 } then want same thing below, it's more complicated because need match , copy both of 2 below (they have "library" , "uuid", have hw , sw").
original code match/copy:
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 } expected output:
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 } keep in mind above code needs placed under "effects {".
your source files have tcl syntax, if execute them tcl code (with appriopriate "unknown procedure" handler), we're good. have first sample "file1.dat" , second "file2.dat"
$ cat process.tcl rename unknown __tcl_unknown proc unknown {cmd body} { puts "$cmd {#$body}" } lassign $argv filename prefix suffix puts $prefix source $filename puts $suffix then
$ tclsh process.tcl file1.dat "libraries {" " proxy { path /system/lib/soundfx/libeffectproxy.so } jdsp { path /system/lib/soundfx/libjamesdsp.so }" 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 } and
$ tclsh process.tcl file2.dat "effects {" " dax { library dax uuid 9d4921da-8225-4f29-aefa-6e6f69726861 }" 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 } it doesn't give indentation want. deal breaker?
Comments
Post a Comment