Skip to content

Instantly share code, notes, and snippets.

@omar-yassin
Created May 8, 2015 20:33
Show Gist options
  • Save omar-yassin/83bdd9cbce2846a68d37 to your computer and use it in GitHub Desktop.
Save omar-yassin/83bdd9cbce2846a68d37 to your computer and use it in GitHub Desktop.
BASH SKELETON: Read from file from the last place you left off
## incomplete; just a guide so I can remember
$log_file
last_length = `cat /tmp/${log_file}_last_length`
current_legnth = 'wc -c $log_file'
if [[ $last_file_length > 0 ]] ; then
diff_length = current_length - last_length
if [[ diff_length >= 0 ]] ; then
## DO WHAT EVER AROUND HERE - should only tail file from where it last read
tail -c +$last_length+1 $log_file
fi
fi
echo $current_legth > /tmp/${log_file}_last_length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment