-
-
Save solidsnack/4636841 to your computer and use it in GitHub Desktop.
One can use read and redirection if the files are line delimited. Preferring while/read to expansion makes for more robust scripts.
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 | |
set -o errexit -o pipefail -o nounset | |
cat_bundle () { | |
local file="$1" | |
echo "" | |
echo "" | |
echo "; ----------------------------------------------------------------------" | |
echo "; $(basename $file)" | |
echo "; ----------------------------------------------------------------------" | |
echo "" | |
cat "$file" | |
} | |
echo | |
echo "SUMMARY" | |
echo "-------" | |
T="$(mktemp -d -t aura-test.XXXX)" | |
mkdir -p dist | |
rm -f dist/tmp | |
ln -s "$T" dist/tmp | |
for i in output/batch/*.bundles.output; do | |
BUNDLE="$(basename "$i" .output)" | |
mkdir "$T/$BUNDLE" | |
grep -rl "Status code: 400" "$i" | sed -e "s!$i/!!" > "$T/$BUNDLE"/awful-input | |
grep -rl "NO RESULTS" "$i" | sed -e "s!$i/!!" > "$T/$BUNDLE"/no-results | |
NUM_BAD="$(wc -l "$T/$BUNDLE"/no-results | awk '{print $1}')" | |
NUM_AWFUL="$(wc -l "$T/$BUNDLE"/awful-input | awk '{print $1}')" | |
echo "$BUNDLE $NUM_BAD bad $NUM_AWFUL awful" | |
TB="$T/$(basename $BUNDLE .bundles)" | |
if [[ $NUM_AWFUL -gt 0 ]]; then | |
while read -r bad; do | |
cat_bundle output/batch/"$BUNDLE".input/"$bad" | |
done < <(cat "$T/$BUNDLE"/awful-input) | |
fi >> "$TB".awful-input.bundles | |
if [[ $NUM_BAD -gt 0 ]]; then | |
while read -r bad; do | |
cat_bundle output/batch/"$BUNDLE".input/"$bad" | |
done < <(cat "$T/$BUNDLE"/no-results) | |
fi >> "$TB".no-results.bundles | |
done | column -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment