#!/bin/bash -e SAVE_TEMPS=false while (( "$#" )); do case "$1" in -s|--save-temps) SAVE_TEMPS=true shift ;; *) # preserve positional arguments PARAMS="$PARAMS $1" shift ;; esac done # set positional arguments in their proper place eval set -- "$PARAMS" if $SAVE_TEMPS; then tmpfile=$(mktemp --tmpdir=$(pwd)) echo "Saving to $tmpfile" else tmpfile=$(mktemp) function finish { rm -rf "$tmpfile" } trap finish EXIT fi # split the wanted and unwanted output awk "BEGIN{RS = \"[\n\r]\"}/^Processor|^PH:[0-9]+ - [0-9]+ [0-9]+/ {print \$0 > \"$tmpfile\"; next}{print \$0; fflush()}" # pass the data to the python scirpt DIR=$( dirname "${BASH_SOURCE[0]}") cat $tmpfile | $DIR/view_halts.py ${PARAMS}