Skip to content

Instantly share code, notes, and snippets.

@xonixx
Last active October 30, 2023 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xonixx/c8ab6b3f192ecbf416ab55dd6536b678 to your computer and use it in GitHub Desktop.
Save xonixx/c8ab6b3f192ecbf416ab55dd6536b678 to your computer and use it in GitHub Desktop.
#!/usr/bin/awk -f
BEGIN {
if (!Tag) { print "must set Tag!"; exit 1 }
}
$1 == (Tag ":") {
StartedSkip = 1
Spaces = index($0, Tag)
next
}
StartedSkip {
match($0,/^\s+/)
spaces1 = RLENGTH
if (spaces1 > Spaces) {
# skipping
} else {
# stop skipping
print
StartedSkip = 0
}
next
}
1
# usage
awk -v Tag='x-code-samples' -f ./yamlrmtag.awk swagger.yaml > swagger_1.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment