title: How to extract the last line from the wget command output?
body: <p><code>DRLAncillary_2014-01-25.tgz</code> file doesn't exist under the remote directory <code>CompressedArchivedAncillary</code>on FTP server host <code>is.sci.gsfc.nasa.gov</code>. </p>
  
  <p>If I use the wget command with <code>--spider</code> option to determine its existence, the following output lines are displayed on the terminal window and pipelined to the output file <strong>/tmp/fileinfo.txt</strong></p>
  
  <pre><code>wget --output-document=/dev/null --spider ftp://is.sci.gsfc.nasa.gov/CompressedArchivedAncillary/DRLAncillary_2014-01-25.tgz 2&gt;&amp;1 | tee /tmp/fileinfo.txt
  
  ==================================================================================
  --2014-02-17 18:20:25--  ftp://is.sci.gsfc.nasa.gov/CompressedArchivedAncillary/DRLAncillary_2014-01-25.tgz
             =&gt; “/dev/null”
  Resolving is.sci.gsfc.nasa.gov... 169.154.128.59
  Connecting to is.sci.gsfc.nasa.gov|169.154.128.59|:21... connected.
  Logging in as anonymous ... Logged in!
  ==&gt; SYST ... done.    ==&gt; PWD ... done.
  ==&gt; TYPE I ... done.  ==&gt; CWD (1) /CompressedArchivedAncillary ... done.
  ==&gt; SIZE DRLAncillary_2014-01-25.tgz ... done.
  ==&gt; PASV ... done.    --2014-02-17 18:20:29--  ftp://is.sci.gsfc.nasa.gov/CompressedArchivedAncillary/DRLAncillary_2014-01-25.tgz
             =&gt; “.listing”
  ==&gt; CWD (1) /CompressedArchivedAncillary ... done.
  ==&gt; PASV ... done.    ==&gt; LIST ... done.
  
       0K .......... .......... .......... ...                   35.6K=0.9s
  
  Removed “.listing”.
  
  No such file “DRLAncillary_2014-01-25.tgz”.
  </code></pre>
  
  <p>==================================================================================</p>
  
  <p><code>DRLAncillary_2014-01-15.tgz</code> file really exists under the remote directory <code>CompressedArchivedAncillary</code> on FTP server host <code>is.sci.gsfc.nasa.gov</code>. </p>
  
  <p>If I use the wget command with <code>--spider</code> option to determine its existence, the following output lines are displayed on the terminal window and pipelined to the output file <strong>/tmp/fileinfo.txt</strong></p>
  
  <pre><code>wget --output-document=/dev/null --spider ftp://is.sci.gsfc.nasa.gov/CompressedArchivedAncillary/DRLAncillary_2014-01-15.tgz 2&gt;&amp;1 | tee /tmp/fileinfo.txt
  
  ==================================================================================
  --2014-02-17 18:22:18--  ftp://is.sci.gsfc.nasa.gov/CompressedArchivedAncillary/DRLAncillary_2014-01-15.tgz
             =&gt; “/dev/null”
  Resolving is.sci.gsfc.nasa.gov... 169.154.128.59
  Connecting to is.sci.gsfc.nasa.gov|169.154.128.59|:21... connected.
  Logging in as anonymous ... Logged in!
  ==&gt; SYST ... done.    ==&gt; PWD ... done.
  ==&gt; TYPE I ... done.  ==&gt; CWD (1) /CompressedArchivedAncillary ... done.
  ==&gt; SIZE DRLAncillary_2014-01-15.tgz ... 1811109782
  ==&gt; PASV ... done.    --2014-02-17 18:22:21--  ftp://is.sci.gsfc.nasa.gov/CompressedArchivedAncillary/DRLAncillary_2014-01-15.tgz
             =&gt; “.listing”
  ==&gt; CWD (1) /CompressedArchivedAncillary ... done.
  ==&gt; PASV ... done.    ==&gt; LIST ... done.
  
       0K .......... .......... .......... ...                   42.0K=0.8s
  
  Removed “.listing”.
  
  File “DRLAncillary_2014-01-15.tgz” exists.
  ==================================================================================
  </code></pre>
  
  <p>The wget command with <strong>--spider</strong> option can fetch the messages of what I want, and store them to the certain file. As you may see from the above listed two paragraphs, which are delimited on both the top and bottom with successive equal sign formed lines: </p>
  
  <p>When the search file doesn't exist, the last line of the output is
  <code>File “DRLAncillary_2014-01-15.tgz” exists</code>.</p>
  
  <p>When the search really exists, the last line of the output reads
  <code>No such file “DRLAncillary_2014-01-25.tgz”.</code></p>
  
  <p>==================================================================================</p>
  
  <p>So my questions are:</p>
  
  <ol>
  <li><p>How can I redirect (with pipe line operator) the wget output to
  one or more filter-enabled commands such as sed, grep, xargs, awk,
  tail, and etc. to extract only the last line from within the stream
  buffer without firstly storing the output in a fixed file, and then
  reading the last line from that file? Furthermore, I hope the
  extracted string will be held in a variable, and I don't expect
  screen quite/clear instead of echoing any piece of message too. </p></li>
  <li><p>At present, I can use the following composite command to get
  the last line from the output file /tmp/fileinfo.txt: 
  tail -2 /tmp/fileinfo.txt | head -1</p>
  
  <p>Although this isn't my ideal solution for a simple file existence checking, if your bash script guru guys can do me a favor to do somewhat modification to my wget command line to echo off terminal window prints, I can make do with it.</p></li>
  </ol>
  
  <p>Thank you in advance!</p>