Created
September 9, 2024 12:59
-
-
Save dewomser/e6dcc0012e6624ed774733f5ee1c9e32 to your computer and use it in GitHub Desktop.
Einen ganzen Ordner mit YAML-Dateien auf validen Syntax prüfen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ruby Gem Psych muss installiert sein. | |
readarray -t a < <(ls *.yaml) | |
for IND in ${!a[@]}; do | |
lolo="${a[$IND]}" | |
ruby -ryaml -e "Psych.parse(File.open('$lolo'))" | |
if [[ $? -ne 0 ]] | |
then | |
echo "$lolo is not valid YAML" | |
# exit 1 | |
# Diese zeile (exit 1) aktivieren wenn beim ersten auftreten eines Fehlers abgebrochen werden soll | |
else | |
echo "$lolo is a valid YAML" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment