YAML 파일 분리

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:~# ./split.sh
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 }}