Skip to content

Instantly share code, notes, and snippets.

@Cayan
Created April 13, 2022 12:57
Show Gist options
  • Save Cayan/a5f995ea23139eb9a51354ddea79ad69 to your computer and use it in GitHub Desktop.
Save Cayan/a5f995ea23139eb9a51354ddea79ad69 to your computer and use it in GitHub Desktop.
Executes a program multiple times and reports on exit codes
#!/bin/bash
TOTAL=100
printf "Starting the script\n"
for i in `seq 1 $TOTAL`; do
trap 'printf "\nExited!"; break;' SIGINT SIGTERM
printf '\r%i / %i' $i $TOTAL
$@ >> debugger.log 2>&1
array+=($?)
done
result=()
for d in ${array[@]} ; do
((result[$d]++))
done
printf "\n\nResults\n"
for x in "${!result[@]}"; do printf "Status code %s reported %s times\n" "$x" "${result[$x]}" ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment