title: Watch file and execute command using tail -f and while read?
body: <p>I am trying to watch a file and execute a command <strong>once</strong> every time the file is changed, ideally with just native bash commands. </p>
  
  <p>This is as far as I have got, but how do I check if I have reached the beginning or end of the file? I realize that <code>tail -f</code> doesn't read EOF so how I can tell that I have reached the end of the file?</p>
  
  <pre class="lang-sh prettyprint-override"><code> tail -f source_file.js | while read line || [[ -n "$line" ]]; 
       # how do I execute a command here just **once**?
   done
  </code></pre>
  
  <p>Answers which don't use <code>tail</code> or <code>while read</code> will be accepted as long as they are native bash commands and about one line. </p>
  
  <p>Perhaps I could zero a variable every time while is called?</p>