YAML 파일 분리

Jmnote (토론 | 기여)님의 2021년 10월 18일 (월) 11:22 판 (새 문서: ==개요== ;YAML 파일 분리 <syntaxhighlight lang='console'> testuser@localhost:~# cat multi.yaml --- name: first metadata: a --- name: second metadata: b --- name: third metadata...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

YAML 파일 분리
testuser@localhost:~# cat multi.yaml
---
name: first
metadata: a
---
name: second
metadata: b
---
name: third
metadata: c
testuser@localhost:~# cat split.sh
#!/bin/bash

rm -rf result
mkdir result

awk '
/name:/{
  close(file)
  file="result/"$NF".yaml"
}
file!="" && !/^--/{
  print > (file)
}
' multi.yaml
testuser@localhost:~# head result/*.yaml
==> result/first.yaml <==
name: first
metadata: a

==> result/second.yaml <==
name: second
metadata: b

==> result/third.yaml <==
name: third
metadata: c

2 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}