Skip to content

Instantly share code, notes, and snippets.

@Oats87
Created April 18, 2023 20:03
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 Oats87/c2de1416f1da101c70a4156cf5e48726 to your computer and use it in GitHub Desktop.
Save Oats87/c2de1416f1da101c70a4156cf5e48726 to your computer and use it in GitHub Desktop.
This requires `yq`, `diff`, and `bash`
#!/bin/bash
FILE=${1:-0}
if [ "${FILE}" = "0" ]; then
echo "need to specify a file"
exit 1
fi
fileNo=$(ls $FILE-split | wc -l | awk '{print $1}')
fileNo=$((fileNo-1))
last=0
for i in $(seq 0 $fileNo); do
echo Diff of $FILE-split/$last.yaml and $FILE-split/$i.yaml:
diff -C 5 $FILE-split/$last.yaml $FILE-split/$i.yaml
last=$i
done
#!/bin/bash
set -e
FILE=${1:-0}
if [ "${FILE}" = "0" ]; then
echo "need to specify a yaml file"
exit 1
fi
mkdir -p $FILE-split
IFS=''
fileIndex=0
while read -r i; do
if [ "${i}" = "---" ]; then
fileIndex=$((fileIndex+1))
fi
echo "${i}" >> $FILE-split/$fileIndex.yaml
done <$FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment