<?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: awk and string variable... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866130#M706331</link>
    <description>How about variables?&lt;BR /&gt;&lt;BR /&gt;start_time="Program Start =&amp;gt; 10:47"&lt;BR /&gt;end_time="Program End =&amp;gt; 12:15"&lt;BR /&gt;&lt;BR /&gt;awk -v start=$start_time end=$end_time '/start/,/end/ {print $0}'&lt;BR /&gt;&lt;BR /&gt;????&lt;BR /&gt;</description>
    <pubDate>Tue, 19 Oct 2004 09:54:47 GMT</pubDate>
    <dc:creator>Jamie Collins</dc:creator>
    <dc:date>2004-10-19T09:54:47Z</dc:date>
    <item>
      <title>awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866126#M706327</link>
      <description>Given the following:&lt;BR /&gt;&lt;BR /&gt;Program Start =&amp;gt; 10:47&lt;BR /&gt;name   time   day&lt;BR /&gt;John   11:09  Monday&lt;BR /&gt;Bill   11:11  Tuesday&lt;BR /&gt;Sam    11:38  Wednesday&lt;BR /&gt;Program End =&amp;gt; 12:15&lt;BR /&gt;&lt;BR /&gt;Program Start =&amp;gt; 15:38&lt;BR /&gt;name   time   day&lt;BR /&gt;John   15:55  Monday&lt;BR /&gt;Bill   16:10  Tuesday&lt;BR /&gt;Sam    18:21  Wednesday&lt;BR /&gt;Program End =&amp;gt; 18:44&lt;BR /&gt;&lt;BR /&gt;How do I print just the first block???&lt;BR /&gt;&lt;BR /&gt;awk '/Program Start =&amp;gt; 10:47/,/Program End =&amp;gt; 12:15/ {print $0}&lt;BR /&gt;&lt;BR /&gt;Putting it in quotes doesn't work...  neither does using a variable or maybe I am just assigning it wrong???&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Oct 2004 09:42:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866126#M706327</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-19T09:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866127#M706328</link>
      <description>You missed a closing single quote: -&lt;BR /&gt;&lt;BR /&gt;awk '/Program Start =&amp;gt; 10:47/,/Program End =&amp;gt; 12:15/ {print $0}' thefile&lt;BR /&gt;&lt;BR /&gt;Also if you just want to display the block you can ommit {print $0} altogether, as awk will just display the matching line(s).</description>
      <pubDate>Tue, 19 Oct 2004 09:47:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866127#M706328</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-10-19T09:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866128#M706329</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I put your sample text into a file named testawk.txt and I got this to work:&lt;BR /&gt;&lt;BR /&gt;&amp;gt;awk '/Program Start =&amp;gt; 10:47/,/Program End =&amp;gt; 12:15/ {print $0}' testawk.txt&lt;BR /&gt;Program Start =&amp;gt; 10:47&lt;BR /&gt;name time day&lt;BR /&gt;John 11:09 Monday&lt;BR /&gt;Bill 11:11 Tuesday&lt;BR /&gt;Sam 11:38 Wednesday&lt;BR /&gt;Program End =&amp;gt; 12:15&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Oct 2004 09:48:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866128#M706329</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2004-10-19T09:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866129#M706330</link>
      <description>In addition, if you wanted to print the first block of such an output, regardless of the time, you could use: -&lt;BR /&gt;&lt;BR /&gt;awk 'found != 1 &amp;amp;&amp;amp; /Program Start/,/Program End/{print ; found=1}' filename&lt;BR /&gt;&lt;BR /&gt;This way the time stamp wouldn't matter, and it would always display just the first block.</description>
      <pubDate>Tue, 19 Oct 2004 09:53:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866129#M706330</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-10-19T09:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866130#M706331</link>
      <description>How about variables?&lt;BR /&gt;&lt;BR /&gt;start_time="Program Start =&amp;gt; 10:47"&lt;BR /&gt;end_time="Program End =&amp;gt; 12:15"&lt;BR /&gt;&lt;BR /&gt;awk -v start=$start_time end=$end_time '/start/,/end/ {print $0}'&lt;BR /&gt;&lt;BR /&gt;????&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Oct 2004 09:54:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866130#M706331</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-19T09:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866131#M706332</link>
      <description>start="Program Start =&amp;gt; 10:47"&lt;BR /&gt;end="Program Start =&amp;gt; 12:15"&lt;BR /&gt;awk "/$start/,/$end/" filename</description>
      <pubDate>Tue, 19 Oct 2004 09:59:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866131#M706332</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-10-19T09:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866132#M706333</link>
      <description>OK...&lt;BR /&gt;&lt;BR /&gt;how about printing out the lines where the first header is the same for every block but the last line is different:&lt;BR /&gt;&lt;BR /&gt;Program Start&lt;BR /&gt;name time day&lt;BR /&gt;John 11:09 Monday&lt;BR /&gt;Bill 11:11 Tuesday&lt;BR /&gt;Sam 11:38 Wednesday&lt;BR /&gt;Program End =&amp;gt; 12:15&lt;BR /&gt;&lt;BR /&gt;Program Start&lt;BR /&gt;name time day&lt;BR /&gt;John 15:55 Monday&lt;BR /&gt;Bill 16:10 Tuesday&lt;BR /&gt;Sam 18:21 Wednesday&lt;BR /&gt;Program End =&amp;gt; 18:44&lt;BR /&gt;&lt;BR /&gt;The awk prints both blocks...&lt;BR /&gt;How do I print just the first one if the header is the same??&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Oct 2004 10:40:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866132#M706333</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-19T10:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866133#M706334</link>
      <description>We can do your's &lt;BR /&gt;&lt;BR /&gt;1&amp;gt; awk '/Program Start =&amp;gt; 10:47/,/Program End =&amp;gt; 12:15/ {print $0}' &lt;INPUTFILE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2&amp;gt; &lt;BR /&gt;   start_time="Program Start =&amp;gt; 10:47"&lt;BR /&gt;   end_time="Program End =&amp;gt; 12:15"&lt;BR /&gt;   awk -v start="$start_time" -v end="$end_time" '{ if ($0==start) while ( $0!=stop ) { getline;if ($0!=stop ) print $0 }}' testfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/INPUTFILE&gt;</description>
      <pubDate>Tue, 19 Oct 2004 10:43:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866133#M706334</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-19T10:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866134#M706335</link>
      <description>We can get first block when the headers are being same then,&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;# cat testfile&lt;BR /&gt;Program Start&lt;BR /&gt;name time day&lt;BR /&gt;John 11:09 Monday&lt;BR /&gt;Bill 11:11 Tuesday&lt;BR /&gt;Sam 11:38 Wednesday&lt;BR /&gt;Program End =&amp;gt; 12:15&lt;BR /&gt;&lt;BR /&gt;Program Start&lt;BR /&gt;name time day&lt;BR /&gt;John 15:55 Monday&lt;BR /&gt;Bill 16:10 Tuesday&lt;BR /&gt;Sam 18:21 Wednesday&lt;BR /&gt;Program End =&amp;gt; 12:15&lt;BR /&gt;&lt;BR /&gt;# awk '/Program Start/,/Program End =&amp;gt; 12:15/ { if ($0=="Program Start") i++; if (i==1) print $0  }' testfile&lt;BR /&gt;Program Start&lt;BR /&gt;name time day&lt;BR /&gt;John 11:09 Monday&lt;BR /&gt;Bill 11:11 Tuesday&lt;BR /&gt;Sam 11:38 Wednesday&lt;BR /&gt;Program End =&amp;gt; 12:15&lt;BR /&gt;&lt;BR /&gt;If you want to change block number then chnage on,&lt;BR /&gt;&lt;BR /&gt; if (i==&lt;NUMBER&gt;)&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;/NUMBER&gt;</description>
      <pubDate>Wed, 20 Oct 2004 00:52:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866134#M706335</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-20T00:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: awk and string variable...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866135#M706336</link>
      <description>thanks</description>
      <pubDate>Thu, 21 Oct 2004 12:33:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-string-variable/m-p/4866135#M706336</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-21T12:33:52Z</dc:date>
    </item>
  </channel>
</rss>

