title: How to delete the last n lines of a file?
body: <p>I was wondering if someone could help me out.</p>
  
  <p>Im writing a bash script and i want to delete the last 12 lines of a specific file.</p>
  
  <p>I have had a look around and somehow come up with the following;</p>
  
  <pre><code>head -n -12 /var/lib/pgsql/9.6/data/pg_hba.conf | tee /var/lib/pgsql/9.6/data/pg_hba.conf &gt;/dev/null
  </code></pre>
  
  <p>But this wipes the file completely.</p>
  
  <p>All i want to do is permanently delete the last 12 lines of that file so i can overwrite it with my own rules.</p>
  
  <p>Any help on where im going wrong?</p>