Added many, many more actions.
This commit is contained in:
16
yq/yq-trim/trim.sh
Normal file
16
yq/yq-trim/trim.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
INPUT="$1"
|
||||
RECURSIVE="$2"
|
||||
|
||||
if [[ -f "$INPUT" ]]; then
|
||||
INPUT=$(cat "$INPUT")
|
||||
fi
|
||||
|
||||
OUTPUT=$(echo "$INPUT" | yq e 'del(.. | select(length == 0))')
|
||||
if [[ "$RECURSIVE" == "true" ]]; then
|
||||
while [ "$(echo "$OUTPUT" | yq e 'map (.. | select (length == 0)) | any')" = "true" ]; do
|
||||
OUTPUT=$(echo "$OUTPUT" | yq e 'del (.. | select (length == 0))')
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$OUTPUT"
|
||||
Reference in New Issue
Block a user