<?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 conditional awk statement in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118367#M150288</link>
    <description>Is it possible to use and 'if' clause with in awk?&lt;BR /&gt;&lt;BR /&gt;If so, could someone provide me with an example.&lt;BR /&gt;&lt;BR /&gt;I am parsing a log file and I want to save a line in one variable if it starts with 'CMD:' (yes I am reading the cron log) and another if it does not.&lt;BR /&gt;&lt;BR /&gt;Any ideas?&lt;BR /&gt;</description>
    <pubDate>Thu, 13 Nov 2003 10:58:38 GMT</pubDate>
    <dc:creator>Jaris Detroye</dc:creator>
    <dc:date>2003-11-13T10:58:38Z</dc:date>
    <item>
      <title>conditional awk statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118367#M150288</link>
      <description>Is it possible to use and 'if' clause with in awk?&lt;BR /&gt;&lt;BR /&gt;If so, could someone provide me with an example.&lt;BR /&gt;&lt;BR /&gt;I am parsing a log file and I want to save a line in one variable if it starts with 'CMD:' (yes I am reading the cron log) and another if it does not.&lt;BR /&gt;&lt;BR /&gt;Any ideas?&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Nov 2003 10:58:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118367#M150288</guid>
      <dc:creator>Jaris Detroye</dc:creator>
      <dc:date>2003-11-13T10:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: conditional awk statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118368#M150289</link>
      <description>I'm not sure if this is what you want but.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=251166" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=251166&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Stuart has some very slick awk code in his post.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 13 Nov 2003 11:04:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118368#M150289</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-11-13T11:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: conditional awk statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118369#M150290</link>
      <description>Create a file my.awk:&lt;BR /&gt;{&lt;BR /&gt;  if ($0 ~ /^CMD:/)&lt;BR /&gt;    {&lt;BR /&gt;      var1 = $0&lt;BR /&gt;    }&lt;BR /&gt;  else&lt;BR /&gt;    {&lt;BR /&gt;      var2 = $0&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;awk -f my.awk &amp;lt; infile&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Nov 2003 11:06:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118369#M150290</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-11-13T11:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: conditional awk statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118370#M150291</link>
      <description>cat file1 |awk '$1 ~ /^CMD:/ {print "save line 1"} $1 !~ /^CMD:/ {print "save line 2"}'&lt;BR /&gt;&lt;BR /&gt;Share and Enjoy! Ian</description>
      <pubDate>Thu, 13 Nov 2003 11:07:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118370#M150291</guid>
      <dc:creator>Ian Dennison_1</dc:creator>
      <dc:date>2003-11-13T11:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: conditional awk statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118371#M150292</link>
      <description>BEGIN{}&lt;BR /&gt;{&lt;BR /&gt;  if (index($0,"CMD:)=1)&lt;BR /&gt;    LINE1=$0&lt;BR /&gt;  else&lt;BR /&gt;    LINE2=$0;&lt;BR /&gt;}&lt;BR /&gt;END{}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enough or more,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Nov 2003 11:08:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118371#M150292</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-13T11:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: conditional awk statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118372#M150293</link>
      <description>the syntax is&lt;BR /&gt;if (expr) statement&lt;BR /&gt;[else statement]&lt;BR /&gt;&lt;BR /&gt;which gives you something like this&lt;BR /&gt;&lt;BR /&gt;if ( outline != "" ) {&lt;BR /&gt;  if ( type == "b" )&lt;BR /&gt;    print something;&lt;BR /&gt;  else&lt;BR /&gt;    print somethingelse;&lt;BR /&gt;}</description>
      <pubDate>Thu, 13 Nov 2003 11:08:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118372#M150293</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-11-13T11:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: conditional awk statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118373#M150294</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;it must of course be CMD:"&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Nov 2003 11:10:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118373#M150294</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-13T11:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: conditional awk statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118374#M150295</link>
      <description>awk '&lt;BR /&gt;$0 ~ /CMD/ {printf "Line no %d contains CMD\n", NR}&lt;BR /&gt;$0 !~ /CMD/ {printf "Line no %d does not contain CMD\n", NR}&lt;BR /&gt;' /var/adm/cron/log&lt;BR /&gt;&lt;BR /&gt;-- Graham&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Nov 2003 11:13:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-awk-statement/m-p/3118374#M150295</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-11-13T11:13:27Z</dc:date>
    </item>
  </channel>
</rss>

