title: Edit a text file using a Bash script
body: <p>I have file which is of the following format:</p>
  
  <pre><code>axel localhost&gt; localhost&gt;
  mike localhost&gt; STORAGE 298390/512000 (58.279296875%) localhost&gt;
  ab localhost&gt; STORAGE 141361/512000 (27.6095703125%) localhost&gt;
  fghi localhost&gt; localhost&gt;
  abcd localhost&gt; STORAGE 165929/512000 (32.4080078125%) localhost&gt;
  lmno localhost&gt; STORAGE 353073/512000 (68.9595703125%) localhost&gt;
  nuon localhost&gt; localhost&gt;
  spar localhost&gt; STORAGE 203766/512000 (39.798046875%) localhost&gt;
  fibo localhost&gt; STORAGE 238204/512000 (46.52421875%) localhost&gt;
  nacci localhost&gt; STORAGE 425737/512000 (83.1517578125%) localhost&gt;
  seldom localhost&gt; STORAGE 69894/512000 (13.651171875%) localhost&gt;
  project localhost&gt; STORAGE 86220/512000 (16.83984375%) localhost&gt;
  eccleston localhost&gt; STORAGE 240084/512000 (46.89140625%) localhost&gt;
  swan localhost&gt; STORAGE 279522/512000 (54.594140625%) localhost&gt;
  </code></pre>
  
  <p>This is the output generated by <code>listquota</code> in cyradm (Cyrus-imapd). I have two questions;</p>
  
  <ul>
  <li>In those lines which have <code>localhost&gt; localhost&gt;</code>, the first word should be written into another file and that line should be deleted.</li>
  <li>For the other lines, the second, third and last columns need to be deleted. </li>
  </ul>
  
  <p>How would I go about achieving this result?</p>
  
  <p><strong>Edit</strong></p>
  
  <p><em>Expected output</em></p>
  
  <pre><code>mike 298390/512000 (58.279296875%)
  ab 141361/512000 (27.6095703125%)
  abcd 165929/512000 (32.4080078125%)
  lmno 353073/512000 (68.9595703125%)
  spar 203766/512000 (39.798046875%)
  fibo 238204/512000 (46.52421875%)
  nacci STORAGE 425737/512000 (83.1517578125%)
  </code></pre>
  
  <p>My loop so far looks something like:</p>
  
  <pre><code>while read thisline; do
      if [ $2 == "localhost&gt;" AND $3 == "localhost&gt;" ];then
          echo $1 &gt;&gt;/root/names.txt
          sed '1d' filename.txt #but this deletes only the first line
      fi
  
  done
  </code></pre>