title: search file content in last n lines of shell script
body: <p><br />
  I use the command the grep file content, and do something.<br />
  However, the file size is growing continuous every second. (will larger than 500MB)<br />
  Due to the performance issue, I want to grep file content in last N lines rather than
  entire file content.<br /></p>
  
  <pre><code>if grep -q "SOMETHING" "/home/andy/log/1.log"; then
      ps -ef | grep "127.0.0.1:50000" | awk '{print $2}' | xargs kill; cat /dev/null &gt; /home/andy/log/1.log
  fi
  </code></pre>
  
  <p>How can I modify the script to grep file content in last N lines?<br />
  Thanks!</p>