title: Looking for powershell equivalent of specific awk command
body: <p>My google-fu's failing me again. The information is (probably) out there, but I can't find it. I know UNIX like the back of my hand, use cygwin etc. however with the increased availability of Powershell on servers, and (on production servers at least) the difficulty at getting cygwin in place, I'm attempting to pick up Powershell. If nothing else, it's another weapon in my arsenal.</p>
  
  <p>Essentially, I'm looking for the Powershell equivalent of the awk command:</p>
  
  <pre><code>awk '$9 == "503" { print $0 }' &lt; access_log
  </code></pre>
  
  <p>For those that don't know awk, this is basically comparing field 9 of the input file, and then executing the block (this is an apache access log, so it returns me all lines from access_log where the HTTP status code returned is 503). Awk handles the split of the file into fields based on whitespace automagically; $0 is the entire line (unadultered), with individual fields going into $1, $2, ... [etc].</p>
  
  <p>I know I can use split like this:</p>
  
  <pre><code>cat access_log | %{ $_.split() }
  </code></pre>
  
  <p>which splits the incoming lines into an array, but I can't work out from here how to use <code>select-object</code> or <code>where-object</code> to select (and output) whole lines based on a given field.</p>
  
  <p>The alternative is <code>select-string</code> but I can't seem to see any way to pass in an expression along the lines of <code>%{ $_.split()[8] -eq "503" }</code>. (I note powershell is zero-based, hence looking at field 8).</p>
  
  <p>I'm not sure if I'm missing something obvious here, and I've not found the right google-fu to give me the info (so wouldn't be suprised if this is a dupe somewhere).</p>
  
  <p>Cheers for any help :-)</p>