Created
December 1, 2015 16:31
-
-
Save rasschaert/4f4e9401f428bde9527b to your computer and use it in GitHub Desktop.
tail -f for a web page (I use it for following Bamboo build logs)
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 | |
command="curl -s $1 2>/dev/null" | |
prev_output=$(eval "$command") | |
echo "$prev_output" | |
while :; do | |
curr_output=$(eval "$command") | |
curr_wc=$(echo "$curr_output" | wc -l) | |
prev_wc=$(echo "$prev_output" | wc -l) | |
wc_diff=$((curr_wc - prev_wc)) | |
if [[ $wc_diff -gt 0 ]]; then | |
echo "$curr_output" | tail -n $wc_diff | |
fi | |
prev_output="$curr_output" | |
sleep 2 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment