["$AccountWide"] =
ファイル間のセクションのすべての行を抽出したいと思います。しかし、私のスクリプトは期待どおりに停止しません。さまざまなソースのコードを組み合わせました。["rules"] =
},
},
awk '/["$AccountWide"]/ {s=1}; # set the flag s to 1 when ["$AccountWide"] is found
(s==1 && /["rules"]/) {p=1}; # set the flag p to 1 when s1=1 and ["rules"] is found
(p==1 && /},/) {s=0}; # set the flag s to 0 when p=1 and }, is found
(p==1 && s==1) p' x # if p=1 and S=1 I want print
データファイルは次のとおりです。
{
["$AccountWide"] =
{
["rules"] =
{
["is learnable by Aerithrìa"] = "type(\"motif\", \"recipe\")\nand needlearn(\"Aerithrìa\")",
["#Launder"] = "false",
["#BagtoHomeBank"] = "countBank(\">\", 0)",
["test"] = "(not rule(\"is protected\"))\nand not fcoismarker(constant(\"FCO ignore\"))\n-- and not fcoismarker(constant(\"FCO Quest Item\"))\nand (\n\t\ttype(\"Masterwrit\") and not rule(\"$pricelimit4Writs\")\n\t)",
},
["ruleSets"] =
ベストアンサー1
awkを使用してください。
$ awk '
/\["\$AccountWide"]/ { state=1 }
state && /\["rules"]/ { state=2 }
state == 2 { print }
/},/ { state=0 }
' file
["rules"] =
{
["is learnable by Aerithrìa"] = "type(\"motif\", \"recipe\")\nand needlearn(\"Aerithrìa\")",
["#Launder"] = "false",
["#BagtoHomeBank"] = "countBank(\">\", 0)",
["test"] = "(not rule(\"is protected\"))\nand not fcoismarker(constant(\"FCO ignore\"))\n-- and not fcoismarker(constant(\"FCO Quest Item\"))\nand (\n\t\ttype(\"Masterwrit\") and not rule(\"$pricelimit4Writs\")\n\t)",
},