title: Passing output from one command as argument to another
body: <p>I have this <em>for</em>:</p>
  
  <pre><code>for i in `ls -1 access.log*`; do tail $i |awk {'print $4'} |cut -d: -f 1 |grep - $i &gt; $i.output; done
  </code></pre>
  
  <p><strong>ls</strong> will give access.log, access.log.1, access.log.2 etc.<br>
  <strong>tail</strong> will give me the last line of each file, which looks like: <code>192.168.1.23 - - [08/Oct/2010:14:05:04 +0300]</code> etc. etc. etc<br>
  <strong>awk+cut</strong> will extract the date (08/Oct/2010 - but different in each access.log), which will allow me to <strong>grep</strong> for it and redirect the output to a separate file.  </p>
  
  <p>But I cannot seem to pass the output of awk+cut to grep.</p>
  
  <p>The reason for all this is that those access logs include lines with more than one date (06/Oct, 07/Oct, 08/Oct) and I just need the lines with the most recent date.  </p>
  
  <p>How can I achieve this?</p>
  
  <p>Thank you.</p>