Skip to content

Instantly share code, notes, and snippets.

@rasschaert
Created December 1, 2015 16:31
Show Gist options
  • Save rasschaert/4f4e9401f428bde9527b to your computer and use it in GitHub Desktop.
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)
#!/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