<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Shell script or command(awk, sed, head or tail) in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961909#M507935</link>
    <description>I want to tail so that the line should end with .... like:&lt;BR /&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;&lt;MILLIS&gt;1167234693507&lt;/MILLIS&gt;&lt;BR /&gt;&lt;SEQUENCE&gt;1&lt;/SEQUENCE&gt;&lt;BR /&gt;&lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;&lt;LEVEL&gt;WARNING&lt;/LEVEL&gt;&lt;BR /&gt;&lt;CLASS&gt;gl.log.Test&lt;/CLASS&gt;&lt;BR /&gt;&lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;&lt;THREAD&gt;10&lt;/THREAD&gt;&lt;BR /&gt;&lt;MESSAGE&gt;This is a test WARNING message&lt;/MESSAGE&gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;&lt;MILLIS&gt;1167234693507&lt;/MILLIS&gt;&lt;BR /&gt;&lt;SEQUENCE&gt;2&lt;/SEQUENCE&gt;&lt;BR /&gt;&lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;&lt;LEVEL&gt;SEVERE&lt;/LEVEL&gt;&lt;BR /&gt;&lt;CLASS&gt;MyCustomLogging&lt;/CLASS&gt;&lt;BR /&gt;&lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;&lt;THREAD&gt;10&lt;/THREAD&gt;&lt;BR /&gt;&lt;MESSAGE&gt;This is a test SEVERE message&lt;/MESSAGE&gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But if I do tail -number filename, I will get:&lt;BR /&gt;&lt;LEVEL&gt;WARNING&lt;/LEVEL&gt;&lt;BR /&gt;&lt;CLASS&gt;gl.log.Test&lt;/CLASS&gt;&lt;BR /&gt;&lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;&lt;THREAD&gt;10&lt;/THREAD&gt;&lt;BR /&gt;&lt;MESSAGE&gt;This is a test WARNING message&lt;/MESSAGE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;&lt;MILLIS&gt;1167234693507&lt;/MILLIS&gt;&lt;BR /&gt;&lt;SEQUENCE&gt;2&lt;/SEQUENCE&gt;&lt;BR /&gt;&lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;&lt;LEVEL&gt;SEVERE&lt;/LEVEL&gt;&lt;BR /&gt;&lt;CLASS&gt;MyCustomLogging&lt;/CLASS&gt;&lt;BR /&gt;&lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;&lt;BR /&gt;Since the file will be growing when I tail it might end without &lt;/RECORD&gt; at the last line. So I should always print within the pattern &lt;RECORD&gt; and &lt;/RECORD&gt;</description>
    <pubDate>Wed, 14 Mar 2007 14:51:18 GMT</pubDate>
    <dc:creator>Qcheck</dc:creator>
    <dc:date>2007-03-14T14:51:18Z</dc:date>
    <item>
      <title>Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961907#M507933</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;There is a file which contains 9 lines within &lt;RECORD&gt; and &lt;/RECORD&gt; &lt;BR /&gt;range and keep appending with too many records. Please see the &lt;BR /&gt;example at the end:&lt;BR /&gt;&lt;BR /&gt;How can I print from that file to tail with in &lt;RECORD&gt; and &lt;/RECORD&gt; &lt;BR /&gt;range, I don't want to break the record when I print. When I tail -n &lt;BR /&gt;100, as that file will be growing, I don't want to get like the &lt;BR /&gt;following:&lt;BR /&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;  &lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;  &lt;MILLIS&gt;1167234693351&lt;/MILLIS&gt;&lt;BR /&gt;  &lt;SEQUENCE&gt;0&lt;/SEQUENCE&gt;&lt;BR /&gt;  &lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;  &lt;LEVEL&gt;INFO&lt;/LEVEL&gt;&lt;BR /&gt;&lt;BR /&gt;Please help me.&lt;BR /&gt;&lt;BR /&gt;Example of the file:(It will be huge, I just gave an instance)&lt;BR /&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;  &lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;  &lt;MILLIS&gt;1167234693351&lt;/MILLIS&gt;&lt;BR /&gt;  &lt;SEQUENCE&gt;0&lt;/SEQUENCE&gt;&lt;BR /&gt;  &lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;  &lt;LEVEL&gt;INFO&lt;/LEVEL&gt;&lt;BR /&gt;  &lt;CLASS&gt;gl.log.Test&lt;/CLASS&gt;&lt;BR /&gt;  &lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;  &lt;THREAD&gt;10&lt;/THREAD&gt;&lt;BR /&gt;  &lt;MESSAGE&gt;This test is a test INFO message&lt;/MESSAGE&gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;  &lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;  &lt;MILLIS&gt;1167234693507&lt;/MILLIS&gt;&lt;BR /&gt;  &lt;SEQUENCE&gt;1&lt;/SEQUENCE&gt;&lt;BR /&gt;  &lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;  &lt;LEVEL&gt;WARNING&lt;/LEVEL&gt;&lt;BR /&gt;  &lt;CLASS&gt;gl.log.Test&lt;/CLASS&gt;&lt;BR /&gt;  &lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;  &lt;THREAD&gt;10&lt;/THREAD&gt;&lt;BR /&gt;  &lt;MESSAGE&gt;This is a test WARNING message&lt;/MESSAGE&gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;  &lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;  &lt;MILLIS&gt;1167234693507&lt;/MILLIS&gt;&lt;BR /&gt;  &lt;SEQUENCE&gt;2&lt;/SEQUENCE&gt;&lt;BR /&gt;  &lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;  &lt;LEVEL&gt;SEVERE&lt;/LEVEL&gt;&lt;BR /&gt;  &lt;CLASS&gt;MyCustomLogging&lt;/CLASS&gt;&lt;BR /&gt;  &lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;  &lt;THREAD&gt;10&lt;/THREAD&gt;&lt;BR /&gt;  &lt;MESSAGE&gt;This is a test SEVERE message&lt;/MESSAGE&gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;BR /&gt;Please assist me....How can I setup the begin and end rules for the above.&lt;BR /&gt;&lt;BR /&gt;awk '/&lt;RECORD&gt;/,/&lt;/RECORD&gt;/ filename, doesn't work.... Any input is greatly appreciated....I wasted whole day working on it..&lt;BR /&gt;&lt;/RECORD&gt;</description>
      <pubDate>Wed, 14 Mar 2007 14:20:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961907#M507933</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-03-14T14:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961908#M507934</link>
      <description>Not sure I follow what you are looking for but try &lt;BR /&gt;&lt;BR /&gt;tail -11 file_name</description>
      <pubDate>Wed, 14 Mar 2007 14:42:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961908#M507934</guid>
      <dc:creator>Court Campbell</dc:creator>
      <dc:date>2007-03-14T14:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961909#M507935</link>
      <description>I want to tail so that the line should end with .... like:&lt;BR /&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;&lt;MILLIS&gt;1167234693507&lt;/MILLIS&gt;&lt;BR /&gt;&lt;SEQUENCE&gt;1&lt;/SEQUENCE&gt;&lt;BR /&gt;&lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;&lt;LEVEL&gt;WARNING&lt;/LEVEL&gt;&lt;BR /&gt;&lt;CLASS&gt;gl.log.Test&lt;/CLASS&gt;&lt;BR /&gt;&lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;&lt;THREAD&gt;10&lt;/THREAD&gt;&lt;BR /&gt;&lt;MESSAGE&gt;This is a test WARNING message&lt;/MESSAGE&gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;&lt;MILLIS&gt;1167234693507&lt;/MILLIS&gt;&lt;BR /&gt;&lt;SEQUENCE&gt;2&lt;/SEQUENCE&gt;&lt;BR /&gt;&lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;&lt;LEVEL&gt;SEVERE&lt;/LEVEL&gt;&lt;BR /&gt;&lt;CLASS&gt;MyCustomLogging&lt;/CLASS&gt;&lt;BR /&gt;&lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;&lt;THREAD&gt;10&lt;/THREAD&gt;&lt;BR /&gt;&lt;MESSAGE&gt;This is a test SEVERE message&lt;/MESSAGE&gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But if I do tail -number filename, I will get:&lt;BR /&gt;&lt;LEVEL&gt;WARNING&lt;/LEVEL&gt;&lt;BR /&gt;&lt;CLASS&gt;gl.log.Test&lt;/CLASS&gt;&lt;BR /&gt;&lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;&lt;THREAD&gt;10&lt;/THREAD&gt;&lt;BR /&gt;&lt;MESSAGE&gt;This is a test WARNING message&lt;/MESSAGE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&lt;DATE&gt;12-27-2006&lt;/DATE&gt;&lt;BR /&gt;&lt;MILLIS&gt;1167234693507&lt;/MILLIS&gt;&lt;BR /&gt;&lt;SEQUENCE&gt;2&lt;/SEQUENCE&gt;&lt;BR /&gt;&lt;LOGGER&gt;SVCS&lt;/LOGGER&gt;&lt;BR /&gt;&lt;LEVEL&gt;SEVERE&lt;/LEVEL&gt;&lt;BR /&gt;&lt;CLASS&gt;MyCustomLogging&lt;/CLASS&gt;&lt;BR /&gt;&lt;METHOD&gt;main&lt;/METHOD&gt;&lt;BR /&gt;&lt;BR /&gt;Since the file will be growing when I tail it might end without &lt;/RECORD&gt; at the last line. So I should always print within the pattern &lt;RECORD&gt; and &lt;/RECORD&gt;</description>
      <pubDate>Wed, 14 Mar 2007 14:51:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961909#M507935</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-03-14T14:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961910#M507936</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;# tail -n20 file | perl -ne 'print if ?&lt;RECORD&gt;?'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/RECORD&gt;</description>
      <pubDate>Wed, 14 Mar 2007 14:54:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961910#M507936</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-14T14:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961911#M507937</link>
      <description>&lt;BR /&gt;So do you want a function which prints only the last whole record block?&lt;BR /&gt;&lt;BR /&gt;This awk program will do that:&lt;BR /&gt;&lt;BR /&gt;(r==1) {rec[tmp,i++]=$0}&lt;BR /&gt;/^&lt;RECORD&gt;/ {i=0;r=1}&lt;BR /&gt;/^&amp;lt;\/record&amp;gt;/ {good=tmp; recs=i-1; tmp=1-tmp}&lt;BR /&gt;END {for (i=0;i&lt;RECS&gt;&lt;/RECS&gt;&lt;BR /&gt;Line 1: If in a record block, stash away lines in tmp array portion of multidimensional record array&lt;BR /&gt;&lt;BR /&gt;Line 2: If start of record block, then remember in a block, and start in begin of temp array&lt;BR /&gt;&lt;BR /&gt;Line 3: If end of record block, promote complete tmp array to 'good' array, flag end, and start new tmp.&lt;BR /&gt;&lt;BR /&gt;Line 4: At END, print last rec array which has last good whole block.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If this is nto exactly what you desire, maybe it help define your exact needs.&lt;BR /&gt;&lt;BR /&gt;For example instead of just two 'big' values you have a circular list of N+1 and print the last N whole blocks.&lt;BR /&gt;&lt;BR /&gt;For very large data volumes the most efficient solution would be to just remember (C, Perl) each &lt;RECORD&gt; location in a circular buffer and at end of file SEEK back to the appropriate one, and restart reading and printing. &lt;BR /&gt;That way you could also JUMP to where a prior run left of.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein van den Heuvel&lt;BR /&gt;HvdH Performance Consulting&lt;BR /&gt;&lt;/RECORD&gt;&lt;/RECORD&gt;</description>
      <pubDate>Wed, 14 Mar 2007 15:05:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961911#M507937</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-03-14T15:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961912#M507938</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;But it is giving only last record....even if I do tail -n60...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Mar 2007 15:05:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961912#M507938</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-03-14T15:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961913#M507939</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; James, But it is giving only last record....even if I do tail -n60...&lt;BR /&gt;&lt;BR /&gt;I understood you to say that you *only* wanted the *last block* that was bounded by &lt;RECORD&gt; and &lt;/RECORD&gt;.&lt;BR /&gt;&lt;BR /&gt;That is what:&lt;BR /&gt;&lt;BR /&gt;# tail -n13 file | perl -ne 'print if ?&lt;RECORD&gt;?'&lt;BR /&gt;&lt;BR /&gt;...was designed to do, using your sample input.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/RECORD&gt;</description>
      <pubDate>Wed, 14 Mar 2007 15:10:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961913#M507939</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-14T15:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961914#M507940</link>
      <description>Your awk example will work if you escape the / in the search string:&lt;BR /&gt; &lt;BR /&gt;awk '/&lt;RECORD&gt;/,/&amp;lt;\/record&amp;gt;/'&lt;BR /&gt; &lt;BR /&gt;awk needs a way to find the search string delimiters so you escape the special characters between the / /. Now finding the last complete section between &lt;RECORD&gt; and &lt;/RECORD&gt; will need some additional awk code.&lt;/RECORD&gt;</description>
      <pubDate>Wed, 14 Mar 2007 15:21:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961914#M507940</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-03-14T15:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961915#M507941</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Ok, if you are feeding it with tail,&lt;BR /&gt;and if &lt;RECORD&gt; &amp;lt;\record&amp;gt; follow each other tightly then you can:&lt;BR /&gt;&lt;BR /&gt;- start remembering all records as soon as &lt;RECORD&gt; is seen&lt;BR /&gt;- remember the last end seen:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;tail x | awk '/^&lt;RECORD&gt;/ {r=1}&lt;BR /&gt;(r) {rec[i++]=$0}&lt;BR /&gt;/^&amp;lt;\/record&amp;gt;/ {end=i}&lt;BR /&gt;END {for (i=0;i&lt;END&gt;&lt;/END&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;/RECORD&gt;&lt;/RECORD&gt;&lt;/RECORD&gt;</description>
      <pubDate>Wed, 14 Mar 2007 15:23:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961915#M507941</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-03-14T15:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961916#M507942</link>
      <description>Morning All,&lt;BR /&gt;&lt;BR /&gt;No no no...I DID NOT say I want only last block..... When I tail I WANT the whole block to be displayed. If the tail doesn't get the whole block at the end then I should be able to trim the last one....The result I should get is from block to block(I mean record to record).... &lt;BR /&gt;&lt;BR /&gt;James! With your command I get the last record, but I dynamically I should be able to display the multiple records, like the following:&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&amp;lt;....constantly 9 lines will be there&amp;gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&amp;lt;....constantly 9 lines will be there&amp;gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&amp;lt;....constantly 9 lines will be there&amp;gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&amp;lt;....constantly 9 lines will be there&amp;gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;BR /&gt;BUT I DO NOT WANT TO DISPLAY:&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&amp;lt;....constantly 9 lines will be there&amp;gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&amp;lt;....constantly 9 lines will be there&amp;gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&amp;lt;....constantly 9 lines will be there&amp;gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&amp;lt;....constantly 9 lines will be there&amp;gt;&lt;BR /&gt;&lt;/RECORD&gt;&lt;BR /&gt;&lt;RECORD&gt;&lt;BR /&gt;&amp;lt;....only 6 lines displayed(any number other than 9 lines&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I hope you all understood what I am trying to explain....&lt;BR /&gt;&lt;BR /&gt;Thank you for all your time in advance!&lt;/RECORD&gt;</description>
      <pubDate>Thu, 15 Mar 2007 07:01:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961916#M507942</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-03-15T07:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961917#M507943</link>
      <description>Hi,&lt;BR /&gt;how about:&lt;BR /&gt;sed -n "1,`grep -n -e'' a.lis| tail -1 | cut -d':' -f1`p" a.lis&lt;BR /&gt;&lt;BR /&gt;print line 1 to (find all /records, then get the line number of the last one)&lt;BR /&gt;a.lis is your datafile&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt; shows how to reward any useful answers given to your questions.</description>
      <pubDate>Thu, 15 Mar 2007 07:21:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961917#M507943</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-15T07:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961918#M507944</link>
      <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;Thank you for your time...It is working, but how can I restrict the tail number like, tail -n 100 or 250 or etc.....&lt;BR /&gt;&lt;BR /&gt;I don't want to get the whole file.....i should be able to get the number of the records, as I want....&lt;BR /&gt;&lt;BR /&gt;like #tail -n 80 filename&lt;BR /&gt;or&lt;BR /&gt;# tail -n 120 filename&lt;BR /&gt;&lt;BR /&gt;Your command is working fine to get the records from block to block, but how can I get the latest 50 records or 100 records etc....Do you know what I am saying....&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Mar 2007 08:21:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961918#M507944</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-03-15T08:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961919#M507945</link>
      <description>So did you try the awk solution I posted earlier?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;tail -n 120 filename | awk '/^&lt;RECORD&gt;/ {r=1}&lt;BR /&gt;(r) {rec[i++]=$0}&lt;BR /&gt;/^&amp;lt;\/record&amp;gt;/ {end=i}&lt;BR /&gt;END {for (i=0;i&lt;END&gt;&lt;/END&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/RECORD&gt;</description>
      <pubDate>Thu, 15 Mar 2007 09:05:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961919#M507945</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-03-15T09:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961920#M507946</link>
      <description>Thank you so much Hein...It worked...when I want 20 lines, with tail 30, I get 20 lines which is two records....but hey no complain, atleast I am getting the records.....&lt;BR /&gt;&lt;BR /&gt;I like scripting, but man! How can I learn this complicated scripting....;)&lt;BR /&gt;&lt;BR /&gt;Thanks again so much for you and everyone who tried to assist me...</description>
      <pubDate>Thu, 15 Mar 2007 09:15:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961920#M507946</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-03-15T09:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961921#M507947</link>
      <description>I *believe* what he wants is to display the last X blocks where:&lt;BR /&gt;&lt;BR /&gt;a) "block" is bounded by &lt;RECORD&gt; &lt;/RECORD&gt;&lt;BR /&gt;b) only complete blocks (ignore any incomplete trailing block)&lt;BR /&gt;c) X is variable&lt;BR /&gt;&lt;BR /&gt;but I could be wrong....</description>
      <pubDate>Mon, 19 Mar 2007 10:39:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961921#M507947</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2007-03-19T10:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961922#M507948</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I think OldSchool guessed right - at least would be a flexible solution, which seems interesting. So try:&lt;BR /&gt;awk -v sta='&lt;RECORD&gt;' -v fin='&lt;/RECORD&gt;' -v num=2 -f last_n_blocks.awk infile&lt;BR /&gt;&lt;BR /&gt;cat last_n_blocks.awk&lt;BR /&gt;$1 ~ sta  {found=-1;i=0;bl++}&lt;BR /&gt;found&amp;lt;0  {rectmp[++i]=$0}&lt;BR /&gt;$1 ~ fin   {found=1; for(j=1;j&amp;lt;=i;j++) {rec[bl%num,j]=rectmp[j]}; rn[bl%num]=i}&lt;BR /&gt;END      {if(found&amp;lt;0) bl--;for(k=(bl-num+1);k&amp;lt;=bl;k++) {for(j=1;j&amp;lt;=rn[bl%num];j++) print rec[k%num,j]}}&lt;BR /&gt;&lt;BR /&gt;You see, you can set the start / end pattern as well as the number of output blocks.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Mon, 19 Mar 2007 13:19:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961922#M507948</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-03-19T13:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961923#M507949</link>
      <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;Thanks for the reply...sorry I was in training so couldn't check this....&lt;BR /&gt;&lt;BR /&gt;Anyways, how do I execute this? My file name is xmlfile. When I tried to execute the following it errored out as last_n_blocks.awk couldn't find. Can you bear with me and explain please....&lt;BR /&gt;&lt;BR /&gt;awk -v sta='&lt;RECORD&gt;' -v fin='&lt;/RECORD&gt;' -v num=2 -f last_n_blocks.awk infile&lt;BR /&gt;&lt;BR /&gt;cat last_n_blocks.awk&lt;BR /&gt;$1 ~ sta  {found=-1;i=0;bl++}&lt;BR /&gt;found&amp;lt;0  {rectmp[++i]=$0}&lt;BR /&gt;$1 ~ fin   {found=1; for(j=1;j&amp;lt;=i;j++) {rec[bl%num,j]=rectmp[j]}; rn[bl%num]=i}&lt;BR /&gt;END      {if(found&amp;lt;0) bl--;for(k=(bl-num+1);k&amp;lt;=bl;k++) {for(j=1;j&amp;lt;=rn[bl%num];j++) print rec[k%num,j]}}&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 22 Mar 2007 07:14:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961923#M507949</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-03-22T07:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961924#M507950</link>
      <description>Hi,&lt;BR /&gt;have you got your last_n_blocks.awk in the correct directory ? Any typing mistakes in the filenames ?&lt;BR /&gt;&lt;BR /&gt;It works for me.</description>
      <pubDate>Thu, 22 Mar 2007 07:22:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961924#M507950</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-22T07:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961925#M507951</link>
      <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;Do you want to me to create last_n_blocks file and insert the following lines as follows:&lt;BR /&gt;&lt;BR /&gt;$1 ~ sta {found=-1;i=0;bl++}&lt;BR /&gt;found&amp;lt;0 {rectmp[++i]=$0}&lt;BR /&gt;$1 ~ fin {found=1; for(j=1;j&amp;lt;=i;j++) {rec[bl%num,j]=rectmp[j]}; rn[bl%num]=i}&lt;BR /&gt;END {if(found&amp;lt;0) bl--;for(k=(bl-num+1);k&amp;lt;=bl;k++) {for(j=1;j&amp;lt;=rn[bl%num];j++) print rec[k%num,j]}}&lt;BR /&gt;&lt;BR /&gt;And then do I need to execute the following at the command prompt:&lt;BR /&gt;&lt;BR /&gt;# awk -v sta='&lt;RECORD&gt;' -v fin='&lt;/RECORD&gt;' -v num=2 -f last_n_blocks.awk xmfile&lt;BR /&gt;&lt;BR /&gt;$$$$ xmlfile is the output of my records file which I would like to trim.....&lt;BR /&gt;&lt;BR /&gt;Thank you...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Mar 2007 07:27:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961925#M507951</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-03-22T07:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or command(awk, sed, head or tail)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961926#M507952</link>
      <description>Yes, that is correct.&lt;BR /&gt;Create the last_n_blocks.awk file and insert the script as is.&lt;BR /&gt;Then run the awk line (Please note your latest post had a typingmistake in the input filename (xmfile rather than xmlfile))</description>
      <pubDate>Thu, 22 Mar 2007 07:38:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-or-command-awk-sed-head-or-tail/m-p/3961926#M507952</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-22T07:38:59Z</dc:date>
    </item>
  </channel>
</rss>

