Jak z pliku z tekstem w markdown wybrać tylko nagłówek w YAML?
quote.md:
---
quote: >-
People just aren't as repeatable as computers are. Nor should we expect them
to be. A shell script or batch file will execute the same instructions, in
the same order, time after time.
author:
- David Thomas
- Andrew Hunt
title: The Pragmatic Programmer
published: 2019
lang: en
---
Ludzie po prostu nie są tak powtarzalni jak komputery. I nie powinniśmy
oczekiwać, że tacy będą. Skrypt powłoki lub plik wsadowy będą wykonywać te same
instrukcje, w tej samej kolejności za każdym razem.
$ sed -ne '/^---/,/^---/{/^---/d;p}' quote.md
quote: >-
People just aren't as repeatable as computers are. Nor should we expect them
to be. A shell script or batch file will execute the same instructions, in
the same order, time after time.
author:
- David Thomas
- Andrew Hunt
title: The Pragmatic Programmer
published: 2019
lang: en
Wynik można teraz sparsować, np. wybierając tylko jedno pole:
$ sed -ne '/^---/,/^---/{/^---/d;p}' quote.md | yq -r '.quote'
People just aren't as repeatable as computers are. Nor should we expect them to
be. A shell script or batch file will execute the same instructions, in the same
order, time after time.