Skip to content

Instantly share code, notes, and snippets.

@ilyaglow
Last active January 24, 2020 12:15
Show Gist options
  • Save ilyaglow/f1a09c4c0c956b48fae75d2225f9cebf to your computer and use it in GitHub Desktop.
Save ilyaglow/f1a09c4c0c956b48fae75d2225f9cebf to your computer and use it in GitHub Desktop.
Simple primitive to monitor output of the command: DISC (do if something changed)
#!/bin/sh
FIRST=y
sh -c "$CMD" > .prev-output
while :
do
if [[ "$FIRST" == "y" ]]; then
FIRST="n"
sleep "$SLEEP"
continue
fi
sh -c "$CMD" > .output
sh -c "comm -1 -3 .prev-output .output || < .output ${TRIGGER_CMD}"
cp .output .prev-output
sleep "$SLEEP"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment