{"id":529,"date":"2023-02-21T15:18:48","date_gmt":"2023-02-21T06:18:48","guid":{"rendered":"https:\/\/hirabay.net\/?p=529"},"modified":"2023-02-21T15:18:53","modified_gmt":"2023-02-21T06:18:53","slug":"%ef%bc%92%e3%81%a4%e3%81%aeyaml%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e6%af%94%e8%bc%83%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/hirabay.net\/?p=529","title":{"rendered":"\uff12\u3064\u306eyaml\u30d5\u30a1\u30a4\u30eb\u3092\u6bd4\u8f03\u3059\u308b"},"content":{"rendered":"\n<p>yaml\u30d5\u30a1\u30a4\u30eb\u306e\u5dee\u5206\u3092\u30a8\u30d3\u30c7\u30f3\u30b9\u3068\u3057\u3066\u6b8b\u3057\u305f\u3044\u3088\u3046\u306a\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u3084\u308a\u65b9\u3092\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n<p><\/p><div class=\"memo \"><div class=\"memo_ttl dfont\"> \u30e1\u30e2<\/div>diff\u3060\u3068\u30c0\u30e1\u306a\u306e\u2026\uff1f<br>\n\u2192 \u5dee\u5206\u306e\u3042\u308b\u884c\u3057\u304b\u8868\u793a\u3055\u308c\u305a\u3001\u300c\u3053\u308c\u3063\u3066\u4f55\u3060\u3063\u3051\uff1f\u300d\u3068\u306a\u308b\u306e\u3067\u30c0\u30e1<\/div>\n\n\n\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/c4179872\/public_html\/hirabay.net\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>110<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/c4179872\/public_html\/hirabay.net\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>115<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/c4179872\/public_html\/hirabay.net\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>122<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">\n  <li class=\"first\">\n    <a href=\"#i-0\">\u5b9f\u884c\u74b0\u5883<\/a>\n  <\/li>\n  <li>\n    <a href=\"#i-1\">\u6e96\u5099<\/a>\n  <\/li>\n  <li>\n    <a href=\"#i-2\">\u624b\u9806<\/a>\n    <ul class=\"menu_level_1\">\n      <li class=\"first\">\n        <a href=\"#i-3\">yaml\u30d5\u30a1\u30a4\u30eb\u3092\u5909\u63db<\/a>\n      <\/li>\n      <li class=\"last\">\n        <a href=\"#i-4\">diff\u3067\u6bd4\u8f03<\/a>\n      <\/li>\n    <\/ul>\n  <\/li>\n  <li class=\"last\">\n    <a href=\"#i-5\">\u4f59\u8ac7<\/a>\n  <\/li>\n<\/ul>\n\n      \n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\"><br>\u5b9f\u884c\u74b0\u5883<\/h2>\n\n\n\n<p>Mac<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-1\">\u6e96\u5099<\/h2>\n\n\n\n<p>\u4e8b\u524d\u306byq\u3092\u5165\u308c\u3066\u304a\u304d\u307e\u3059<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Bash\"><code>$ brew install yq<\/code><\/pre><\/div>\n\n\n<p><\/p><div class=\"memo alert\"><div class=\"memo_ttl dfont\"> \u6ce8\u610f<\/div>pip install\u3067\u5165\u308c\u305fyq\u3068\u4f7f\u3044\u65b9\u304c\u7570\u306a\u308a\u307e\u3059\u3002<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-2\">\u624b\u9806<\/h2>\n\n\n\n<p>\u4f8b\u3068\u3057\u3066\u3001\u300c<code>sample1.yaml<\/code>\u300d\u300c<code>sample2.yaml<\/code>\u300d\u306e\uff12\u30d5\u30a1\u30a4\u30eb\u3092\u6bd4\u8f03\u3059\u308b\u3082\u306e\u3068\u3057\u3066\u30b3\u30de\u30f3\u30c9\u3092\u8a18\u8f09\u3057\u307e\u3059<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-yaml\" data-file=\"sample1.yaml\" data-lang=\"Yaml\"><code>path1:\n  path2:\n    key1: value1\n    key2: value2<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-yaml\" data-file=\"sample2.yaml\" data-lang=\"Yaml\"><code>path1:\n  path2:\n    key1: value1\n    key3: value3<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">yaml\u30d5\u30a1\u30a4\u30eb\u3092\u5909\u63db<\/h3>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067properties\u5f62\u5f0f\u306b\u5909\u63db\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Bash\"><code>$ yq eval '.. | select((tag == \"!!map\" or tag == \"!!seq\") | not) | (path | join(\".\")) + \"=\" + .' sample1.yaml | sort &gt; sample1.properties\n$ yq eval '.. | select((tag == \"!!map\" or tag == \"!!seq\") | not) | (path | join(\".\")) + \"=\" + .' sample2.yaml | sort &gt; sample2.properties<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u308c\u3067<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-yaml\" data-lang=\"Yaml\"><code>path1:\n  path2:\n    key1: value1\n    key2: value2<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306eyaml\u304c<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-properties\" data-lang=\".properties\"><code>path1.path2.key1=value1\npath1.path2.key2=value2<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">diff\u3067\u6bd4\u8f03<\/h3>\n\n\n\n<p>1\u3067\u51fa\u529b\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092diff\u3067\u6bd4\u8f03\u3057\u307e\u3059<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Bash\"><code>$ diff sample1.properties sample2.properties\n2c2\n&lt; path1.path2.key2=value2\n---\n&gt; path1.path2.key3=value3<\/code><\/pre><\/div>\n\n\n\n<p>\u308f\u304b\u308a\u3084\u3059\u3044\u2728<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-5\">\u4f59\u8ac7<\/h2>\n\n\n\n<p>\u3061\u306a\u307f\u306b\u5143\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u6bd4\u8f03\u3059\u308b\u3068<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Bash\"><code>$ diff sample1.yaml sample2.yaml\n4c4\n&lt;     key2: value2\n---\n&gt;     key3: value3<\/code><\/pre><\/div>\n\n\n\n<p>\u306a\u3093\u306ekey\u3060\u3002\u3002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>yaml\u30d5\u30a1\u30a4\u30eb\u306e\u5dee\u5206\u3092\u30a8\u30d3\u30c7\u30f3\u30b9\u3068\u3057\u3066\u6b8b\u3057\u305f\u3044\u3088\u3046\u306a\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u3084\u308a\u65b9\u3092\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002 Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/c4179872\/pub &#8230; <\/p>\n","protected":false},"author":1,"featured_media":531,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[88,89],"class_list":{"0":"post-529","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-6","8":"tag-yaml","9":"tag-yq"},"jetpack_featured_media_url":"https:\/\/hirabay.net\/wp-content\/uploads\/2023\/02\/459e0414f26a271777ae6ea4740e0bf4.png","_links":{"self":[{"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/posts\/529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=529"}],"version-history":[{"count":2,"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/posts\/529\/revisions"}],"predecessor-version":[{"id":532,"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/posts\/529\/revisions\/532"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/media\/531"}],"wp:attachment":[{"href":"https:\/\/hirabay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}