<?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 More help with awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960818#M814175</link>
    <description>In my previous post &lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x127e38dfa974d711abdc0090277a778c,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x127e38dfa974d711abdc0090277a778c,00.html&lt;/A&gt; I received lots of good help with my awk script. I have extended that script and now I need more help.&lt;BR /&gt;&lt;BR /&gt;I have added local variables that get set with values and printed at the END. The single line output is intended for use with Oracle SQLLDR to save this info in a database table for later retrieval and analysis.   Anyway, I am able to get all the local variables except 'srvr' to print on the single line. It seems to have something to do with the position of that variable on the line as it prints just fine when it is the last item. Here's the revised script:&lt;BR /&gt;&lt;BR /&gt;   awk -v ptnum=$portnum            '($2 == "is" &amp;amp;&amp;amp; $3 == "up,") {&lt;BR /&gt;                  print "Port# " ptnum  " Status: " $3 " Protocol: " $7&lt;BR /&gt;                  pnum=ptnum&lt;BR /&gt;                  pstat=$3&lt;BR /&gt;                  protstat=$7&lt;BR /&gt;                  next}&lt;BR /&gt;            ($1 == "Description:") {&lt;BR /&gt;                  print "      Server: " substr($0,16,30)&lt;BR /&gt;                  srvr=substr($0,16,30)&lt;BR /&gt;                  next}&lt;BR /&gt;            ($2 == "packets" &amp;amp;&amp;amp; $3 == "input,") {&lt;BR /&gt;                  print "      Pkt In: " $1 "  Byte In: " $4&lt;BR /&gt;                  inp_pkt=$1&lt;BR /&gt;                  inp_byt=$4&lt;BR /&gt;                  next}&lt;BR /&gt;            ($2 == "input" &amp;amp;&amp;amp; $3 == "errors,") {&lt;BR /&gt;                  print "      IN Errs: " $1 " CRC: " $4&lt;BR /&gt;                  inp_err=$1&lt;BR /&gt;                  inp_crc=$4&lt;BR /&gt;                  next}&lt;BR /&gt;            ($2 == "packets" &amp;amp;&amp;amp; $3 == "output,") {&lt;BR /&gt;                  print "      Pkt Out: " $1 "  Byte Out: " $4&lt;BR /&gt;                  out_pkt=$1&lt;BR /&gt;                  out_byt=$4&lt;BR /&gt;                  next}&lt;BR /&gt;            ($2 == "output" &amp;amp;&amp;amp; $3 == "errors,") {&lt;BR /&gt;                  print "      OUT Errs: " $1 "  Collisions: " $4&lt;BR /&gt;                  out_err=$1&lt;BR /&gt;                  colls=$4&lt;BR /&gt;                  next}&lt;BR /&gt;           END {&lt;BR /&gt;            print srvr "," ptnum  pstat "," protstat "," inp_pkt "," inp_byt "," inp_err "," inp_crc "," out_pkt "," out&lt;BR /&gt;_byt "," out_err "," colls "," }&lt;BR /&gt;               ' $pfile &amp;gt;&amp;gt; gpi.awk_out&lt;BR /&gt;&lt;BR /&gt;That last 'print' statement is what I'm after.&lt;BR /&gt;</description>
    <pubDate>Mon, 28 Apr 2003 17:10:43 GMT</pubDate>
    <dc:creator>Don Spare</dc:creator>
    <dc:date>2003-04-28T17:10:43Z</dc:date>
    <item>
      <title>More help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960818#M814175</link>
      <description>In my previous post &lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x127e38dfa974d711abdc0090277a778c,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x127e38dfa974d711abdc0090277a778c,00.html&lt;/A&gt; I received lots of good help with my awk script. I have extended that script and now I need more help.&lt;BR /&gt;&lt;BR /&gt;I have added local variables that get set with values and printed at the END. The single line output is intended for use with Oracle SQLLDR to save this info in a database table for later retrieval and analysis.   Anyway, I am able to get all the local variables except 'srvr' to print on the single line. It seems to have something to do with the position of that variable on the line as it prints just fine when it is the last item. Here's the revised script:&lt;BR /&gt;&lt;BR /&gt;   awk -v ptnum=$portnum            '($2 == "is" &amp;amp;&amp;amp; $3 == "up,") {&lt;BR /&gt;                  print "Port# " ptnum  " Status: " $3 " Protocol: " $7&lt;BR /&gt;                  pnum=ptnum&lt;BR /&gt;                  pstat=$3&lt;BR /&gt;                  protstat=$7&lt;BR /&gt;                  next}&lt;BR /&gt;            ($1 == "Description:") {&lt;BR /&gt;                  print "      Server: " substr($0,16,30)&lt;BR /&gt;                  srvr=substr($0,16,30)&lt;BR /&gt;                  next}&lt;BR /&gt;            ($2 == "packets" &amp;amp;&amp;amp; $3 == "input,") {&lt;BR /&gt;                  print "      Pkt In: " $1 "  Byte In: " $4&lt;BR /&gt;                  inp_pkt=$1&lt;BR /&gt;                  inp_byt=$4&lt;BR /&gt;                  next}&lt;BR /&gt;            ($2 == "input" &amp;amp;&amp;amp; $3 == "errors,") {&lt;BR /&gt;                  print "      IN Errs: " $1 " CRC: " $4&lt;BR /&gt;                  inp_err=$1&lt;BR /&gt;                  inp_crc=$4&lt;BR /&gt;                  next}&lt;BR /&gt;            ($2 == "packets" &amp;amp;&amp;amp; $3 == "output,") {&lt;BR /&gt;                  print "      Pkt Out: " $1 "  Byte Out: " $4&lt;BR /&gt;                  out_pkt=$1&lt;BR /&gt;                  out_byt=$4&lt;BR /&gt;                  next}&lt;BR /&gt;            ($2 == "output" &amp;amp;&amp;amp; $3 == "errors,") {&lt;BR /&gt;                  print "      OUT Errs: " $1 "  Collisions: " $4&lt;BR /&gt;                  out_err=$1&lt;BR /&gt;                  colls=$4&lt;BR /&gt;                  next}&lt;BR /&gt;           END {&lt;BR /&gt;            print srvr "," ptnum  pstat "," protstat "," inp_pkt "," inp_byt "," inp_err "," inp_crc "," out_pkt "," out&lt;BR /&gt;_byt "," out_err "," colls "," }&lt;BR /&gt;               ' $pfile &amp;gt;&amp;gt; gpi.awk_out&lt;BR /&gt;&lt;BR /&gt;That last 'print' statement is what I'm after.&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Apr 2003 17:10:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960818#M814175</guid>
      <dc:creator>Don Spare</dc:creator>
      <dc:date>2003-04-28T17:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: More help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960819#M814176</link>
      <description>Boy, did I get this wrong. The problem is that the value of 'srvr' contains an embedded ^M. So what I really need to do is remove the ^M from the file before I send it through awk. I've tried sed but can't seem to get the right combinations.&lt;BR /&gt;&lt;BR /&gt;What is a good way to strip ^M characters from a file?</description>
      <pubDate>Mon, 28 Apr 2003 18:25:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960819#M814176</guid>
      <dc:creator>Don Spare</dc:creator>
      <dc:date>2003-04-28T18:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: More help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960820#M814177</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;There are a couple of ways to strip the ^M characters out of the file.  One way is to use the dos2ux command.  Another way is to use sed like this:&lt;BR /&gt;&lt;BR /&gt;sed 's/.$//'&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Apr 2003 18:39:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960820#M814177</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-04-28T18:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: More help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960821#M814178</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;'sed' can correct this.  You will need to press the CONTROL key, and while holding down the CONTROL key, press a lowercase "v".  Continue to hold down the CONTROL key and press "M".  This sequence generates a carriage return.  This sequence is documented in 'ascii(5)'.  When done properly, it will look like:&lt;BR /&gt;&lt;BR /&gt;# echo "This is^M botched with CRs^M and needs to be fixed"|sed 's/^M//g'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 28 Apr 2003 18:39:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960821#M814178</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-04-28T18:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: More help with awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960822#M814179</link>
      <description>My weapon of choice for this would be "tr"&lt;BR /&gt;&lt;BR /&gt;tr -d "[\015]" &amp;lt; infile | awk&lt;BR /&gt;&lt;BR /&gt;Octal 015 is your ^M.&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Apr 2003 18:43:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/more-help-with-awk/m-p/2960822#M814179</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-04-28T18:43:23Z</dc:date>
    </item>
  </channel>
</rss>

