<?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: help with awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398578#M706019</link>
    <description>Since we've updated it a few times.. I'll just paste what I have and where it sits...&lt;BR /&gt;&lt;BR /&gt;&amp;gt;cat dummy3.out&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 John Wayne&lt;BR /&gt;2 Bill Smith&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 Mark Williams&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;cat dummy3.awk&lt;BR /&gt;BEGIN {flag=0}&lt;BR /&gt;{if ( flag == 1 ) print $0;}&lt;BR /&gt;/Start/ {flag = 1;}&lt;BR /&gt;/Stop/ {flag = 0;print "";}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;awk -f dummy3.awk dummy3.out&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 John Wayne&lt;BR /&gt;2 Bill Smith&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 Mark Williams&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
    <pubDate>Tue, 12 Oct 2004 16:43:35 GMT</pubDate>
    <dc:creator>Jamie Collins</dc:creator>
    <dc:date>2004-10-12T16:43:35Z</dc:date>
    <item>
      <title>help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398568#M706007</link>
      <description>I am doing pattern searches with a 'start' and 'stop' string and want to manipulate the data inside the result set.  Need to know how to do this for multiple result sets returned from the search...</description>
      <pubDate>Tue, 12 Oct 2004 15:08:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398568#M706007</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-12T15:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398569#M706008</link>
      <description>Since you site no specific examples, I'll be quite general.&lt;BR /&gt;&lt;BR /&gt;I would do this in two parts.  First gleen out the text you want via the start/stop parameters to a temp file.  Then awk the temp file contents as necessary to achive the desired output.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2004 15:22:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398569#M706008</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2004-10-12T15:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398570#M706009</link>
      <description>Here is an example...&lt;BR /&gt;&lt;BR /&gt;file:&lt;BR /&gt;&lt;BR /&gt;Start&lt;BR /&gt;id  fname  lname&lt;BR /&gt;--  -----  -----&lt;BR /&gt;1   John   Wayne&lt;BR /&gt;2   Bill   Smith&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id  fname  lname&lt;BR /&gt;--  -----  -----&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id  fname  lname&lt;BR /&gt;--  -----  -----&lt;BR /&gt;1   Mark   Williams&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I don't want the 'chunk' with no names in it.&lt;BR /&gt;awk:&lt;BR /&gt;&lt;BR /&gt;/Start/,/Stop/ {print}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 12 Oct 2004 15:27:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398570#M706009</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-12T15:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398571#M706010</link>
      <description>We can do this as,&lt;BR /&gt;&lt;BR /&gt;#  cat &amp;gt; testfile&lt;BR /&gt;hai test&lt;BR /&gt;start&lt;BR /&gt;testfile&lt;BR /&gt;okei content&lt;BR /&gt;itrc forum&lt;BR /&gt;stop&lt;BR /&gt;over&lt;BR /&gt;&lt;BR /&gt;# awk '/start/,/stop/ { print $0 }' testfile&lt;BR /&gt;start&lt;BR /&gt;testfile&lt;BR /&gt;okei content&lt;BR /&gt;itrc forum&lt;BR /&gt;stop&lt;BR /&gt;&lt;BR /&gt;If you want to get only contents inside limit exactly then,&lt;BR /&gt;&lt;BR /&gt;# awk '/start/,/stop/ { if ( $0 != "start" &amp;amp;&amp;amp; $0 != "stop" ) print $0 }' testfile&lt;BR /&gt;testfile&lt;BR /&gt;okei content&lt;BR /&gt;itrc forum&lt;BR /&gt;&lt;BR /&gt;It will give you the way there.&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2004 15:29:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398571#M706010</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-12T15:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398572#M706011</link>
      <description>if you just want the lines with names on it, and as in your example those lines start with a number, then&lt;BR /&gt;&lt;BR /&gt;awk '$1 ~ /[0-9]*/ {print $0;}'</description>
      <pubDate>Tue, 12 Oct 2004 15:43:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398572#M706011</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-10-12T15:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398573#M706012</link>
      <description>Based on:&lt;BR /&gt;&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 John Wayne&lt;BR /&gt;2 Bill Smith&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 Mark Williams&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need the output to look like this:&lt;BR /&gt;&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 John Wayne&lt;BR /&gt;2 Bill Smith&lt;BR /&gt;&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 Mark Williams&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 12 Oct 2004 15:54:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398573#M706012</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-12T15:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398574#M706013</link>
      <description>awk '&lt;BR /&gt;/start/ {&lt;BR /&gt;# set print flag, don't print this line&lt;BR /&gt;flag=1;}&lt;BR /&gt;/stop/ {&lt;BR /&gt;#unset print flag, don't print this line&lt;BR /&gt;flag=0;&lt;BR /&gt;#print blank line&lt;BR /&gt;print "";}&lt;BR /&gt;{print $0;}' yourFile&lt;BR /&gt;&lt;BR /&gt;a uncommented version&lt;BR /&gt;&lt;BR /&gt;awk '/start/{flag=1;}&lt;BR /&gt;/stop/ {flag=0;print "";}&lt;BR /&gt;{print $0;}'&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2004 16:15:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398574#M706013</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-10-12T16:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398575#M706014</link>
      <description>oops&lt;BR /&gt;&lt;BR /&gt;this  {print $0;}' &lt;BR /&gt;&lt;BR /&gt;should have been&lt;BR /&gt;&lt;BR /&gt;{if ( flag == 1 ) print $0;}'</description>
      <pubDate>Tue, 12 Oct 2004 16:28:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398575#M706014</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-10-12T16:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398576#M706015</link>
      <description>I get the following:&lt;BR /&gt;&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 John Wayne&lt;BR /&gt;2 Bill Smith&lt;BR /&gt;&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 Mark Williams&lt;BR /&gt;&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Same as before but with a space before the Stop...  Is there any way awk can process the 'chunk' one at a time...  I know that if there are no names in the list it returns 4 rows...  the Start and Stop, the header and the dashes...  I can't check if the NR is 4 just for each search?</description>
      <pubDate>Tue, 12 Oct 2004 16:29:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398576#M706015</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-12T16:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398577#M706016</link>
      <description>and of course the if (flag&lt;BR /&gt;needs to be before the /start/&lt;BR /&gt;&lt;BR /&gt;awk '/start/{flag=1;}&lt;BR /&gt;/stop/ {flag=0;print "";}&lt;BR /&gt;{print $0;}' &lt;BR /&gt;&lt;BR /&gt;should be&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN {flag=0)&lt;BR /&gt;{if ( flag == 1 ) print $0;}&lt;BR /&gt;/start/ {flag = 1;}&lt;BR /&gt;/stop/ {flag = 0;print "";}'&lt;BR /&gt;&lt;BR /&gt;oh boy what was i thinking before&lt;BR /&gt;better go home before i ...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2004 16:32:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398577#M706016</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-10-12T16:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398578#M706019</link>
      <description>Since we've updated it a few times.. I'll just paste what I have and where it sits...&lt;BR /&gt;&lt;BR /&gt;&amp;gt;cat dummy3.out&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 John Wayne&lt;BR /&gt;2 Bill Smith&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 Mark Williams&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;cat dummy3.awk&lt;BR /&gt;BEGIN {flag=0}&lt;BR /&gt;{if ( flag == 1 ) print $0;}&lt;BR /&gt;/Start/ {flag = 1;}&lt;BR /&gt;/Stop/ {flag = 0;print "";}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;awk -f dummy3.awk dummy3.out&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 John Wayne&lt;BR /&gt;2 Bill Smith&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 Mark Williams&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 12 Oct 2004 16:43:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398578#M706019</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-12T16:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398579#M706022</link>
      <description>change&lt;BR /&gt;&lt;BR /&gt;{if ( flag == 1 ) print $0;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;to&lt;BR /&gt;&lt;BR /&gt;{if ( flag == 1 &amp;amp;&amp;amp; $1 !~ "stop" ) print $0;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sorry for all the incorrect scripts&lt;BR /&gt;&lt;BR /&gt;should have tested before typing</description>
      <pubDate>Tue, 12 Oct 2004 16:49:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398579#M706022</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-10-12T16:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398580#M706024</link>
      <description>&lt;BR /&gt;Something like this?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN{xx=0}/Start/{x=1}/Stop/{if (xx&amp;gt;3){for(i=0;i&lt;XX&gt;&lt;/XX&gt;&lt;BR /&gt;Store each line seen in array l[], incrementing index by x which may be 0 or 1.&lt;BR /&gt;&lt;BR /&gt;Only after seeing start, set array index increment x to 1&lt;BR /&gt;&lt;BR /&gt;When seeing stop, print all array lines if there are enough.&lt;BR /&gt;&lt;BR /&gt;When seeing stop clear increment.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2004 20:50:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398580#M706024</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-10-12T20:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398581#M706025</link>
      <description>Try this:&lt;BR /&gt;&lt;BR /&gt;INPUT DATA&lt;BR /&gt;$ cat infile&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 John Wayne&lt;BR /&gt;102982 Bill Smit&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;Stop&lt;BR /&gt;Start&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 Mark Williams&lt;BR /&gt;Stop&lt;BR /&gt;&lt;BR /&gt;AWK CODE:&lt;BR /&gt;$ awk '/^[[:digit:]]+ /' infile&lt;BR /&gt;&lt;BR /&gt;RESULT:&lt;BR /&gt;1 John Wayne&lt;BR /&gt;102982 Bill Smith&lt;BR /&gt;1 Mark Williams</description>
      <pubDate>Tue, 12 Oct 2004 21:53:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398581#M706025</guid>
      <dc:creator>Trevor Dyson</dc:creator>
      <dc:date>2004-10-12T21:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398582#M706026</link>
      <description>...or if you want to be certain only matched between the Start and Stop flags are shown:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;awk ' /Start/,/Stop/ { if(match($0,/^[[:digit:]]+ /)) print $0 }' infile</description>
      <pubDate>Tue, 12 Oct 2004 21:59:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398582#M706026</guid>
      <dc:creator>Trevor Dyson</dc:creator>
      <dc:date>2004-10-12T21:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398583#M706027</link>
      <description>Hey Trevor, from the sample Jamie provided he want to print the header also. So you need to build in a bit oof memory, and/or just hardcode the header and add a 'header printed' flag.&lt;BR /&gt;&lt;BR /&gt;Looking back my example printed too much (I misread an other example to mean that the start and stop line would be needed.&lt;BR /&gt;&lt;BR /&gt;Here is an other try:&lt;BR /&gt;&lt;BR /&gt;awk '/Start/{x=1;y=0}/Stop/{if (y&amp;gt;3){l[y]="\n"; while(i++&lt;Y&gt;&lt;/Y&gt;&lt;BR /&gt;This outputs:&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 John Wayne&lt;BR /&gt;2 Bill Smith&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;id fname lname&lt;BR /&gt;-- ----- -----&lt;BR /&gt;1 Mark Williams&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2004 23:30:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/3398583#M706027</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-10-12T23:30:06Z</dc:date>
    </item>
  </channel>
</rss>

