<?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 Awk with sub in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783985#M833543</link>
    <description>Hi all&lt;BR /&gt;&lt;BR /&gt;I have a file thats looks like this&lt;BR /&gt;&lt;BR /&gt;111 222 0000 9999 RABC:AB fat 1 3 5&lt;BR /&gt;111 223 0000 9999 RABC:AC cat 1 34 5&lt;BR /&gt; &lt;BR /&gt;What I would like to do is sub(0000,XXXX &amp;amp;&amp;amp; sub(9999,XXXX) when awk {if($5 == "???:A[A-Z]")&lt;BR /&gt;How can I put this in the awk statement. &lt;BR /&gt;&lt;BR /&gt;Thanks in advanced&lt;BR /&gt;Chris&lt;BR /&gt;</description>
    <pubDate>Mon, 12 Aug 2002 11:49:42 GMT</pubDate>
    <dc:creator>Chris Frangandonis</dc:creator>
    <dc:date>2002-08-12T11:49:42Z</dc:date>
    <item>
      <title>Awk with sub</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783985#M833543</link>
      <description>Hi all&lt;BR /&gt;&lt;BR /&gt;I have a file thats looks like this&lt;BR /&gt;&lt;BR /&gt;111 222 0000 9999 RABC:AB fat 1 3 5&lt;BR /&gt;111 223 0000 9999 RABC:AC cat 1 34 5&lt;BR /&gt; &lt;BR /&gt;What I would like to do is sub(0000,XXXX &amp;amp;&amp;amp; sub(9999,XXXX) when awk {if($5 == "???:A[A-Z]")&lt;BR /&gt;How can I put this in the awk statement. &lt;BR /&gt;&lt;BR /&gt;Thanks in advanced&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Aug 2002 11:49:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783985#M833543</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-08-12T11:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Awk with sub</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783986#M833544</link>
      <description>Can you please a little more clear? Your first sub has no ')', and your awk has a ??? but shouldn't it have ???? (4 char's) ??&lt;BR /&gt;Please just give us some input and output, then we will write you the blackbox.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ceesjan&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Aug 2002 11:53:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783986#M833544</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-08-12T11:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Awk with sub</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783987#M833545</link>
      <description>Hi Ceesja,&lt;BR /&gt;&lt;BR /&gt;Search in the file, and when a pattern RABC:AC is found for eg RABC:AB or RABC:AC or ????:A[A-Z] is found, then sub 0000 99999 to XXXX for 0000 and XXXX for 9999. The result should look like this&lt;BR /&gt;&lt;BR /&gt;111 222 XXXX XXXX RABC:AB fat 1 3 5&lt;BR /&gt;111 223 XXXX XXXX RABC:AC cat 1 34 5&lt;BR /&gt;&lt;BR /&gt;Thanks Once again&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Aug 2002 12:12:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783987#M833545</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-08-12T12:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Awk with sub</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783988#M833546</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;Try this awk command-&lt;BR /&gt;&lt;BR /&gt;awk '$5~/....:A[A-Z]/{$3="XXXX"; $4="XXXX" ; print $0}' yourinputfile.txt&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 12 Aug 2002 12:55:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783988#M833546</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-08-12T12:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Awk with sub</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783989#M833547</link>
      <description>What about this:&lt;BR /&gt;&lt;BR /&gt;awk '{&lt;BR /&gt;sub(/0000/,"XXXX");&lt;BR /&gt;sub(/9999/,"XXXX");&lt;BR /&gt;print&lt;BR /&gt;}' input&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ceesjan</description>
      <pubDate>Mon, 12 Aug 2002 12:58:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783989#M833547</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-08-12T12:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Awk with sub</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783990#M833548</link>
      <description>My first awk script assumed only lines with ....:A[A-Z] would be substituted and printed.&lt;BR /&gt;&lt;BR /&gt;Here is another version, that prints all lines, but only changes those lines that match the pattern.&lt;BR /&gt;&lt;BR /&gt;awk '$5~/....:A[A-Z]/{$3="XXXX"; $4="XXXX"};{print $0}' yourinputfile.txt&lt;BR /&gt;&lt;BR /&gt;Hope this helps...&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Aug 2002 13:09:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783990#M833548</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-08-12T13:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Awk with sub</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783991#M833549</link>
      <description>Hi Rod,&lt;BR /&gt;&lt;BR /&gt;Great stuff. I tried this one with results which is incorrect. Could you PLEASE explain why.&lt;BR /&gt;&lt;BR /&gt;cat FILE | awk -v var="[0-9][0-9][0-9][0-9]" -v var2="XXXX" '{if ($5 == "....:A[A-Z]");{sub(var1,var2,$3)};{print $0}}' | more&lt;BR /&gt;&lt;BR /&gt;Many Thanks to All&lt;BR /&gt;Chris</description>
      <pubDate>Mon, 12 Aug 2002 18:08:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783991#M833549</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-08-12T18:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Awk with sub</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783992#M833550</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;In your sample you set "var=". Did you mean var1= ?&lt;BR /&gt;&lt;BR /&gt;You are also doing a comparsion using "$5 ==", this should be "$5 ~" so that it does a regular expression compare.&lt;BR /&gt;&lt;BR /&gt;The regular expression I believe needs to be enclosed with "/".&lt;BR /&gt;&lt;BR /&gt;Remove the ";" after the if ($5 ... ).&lt;BR /&gt;&lt;BR /&gt;Try this-&lt;BR /&gt;&lt;BR /&gt;cat FILE | awk -v var1="[0-9][0-9][0-9][0-9]" -v var2="XXXX" '{if ($5 ~ /....:A[A-Z]/){sub(var1,var2,$3)};{print $0}}' | more &lt;BR /&gt;&lt;BR /&gt;Hope this Helps.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Aug 2002 20:18:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783992#M833550</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-08-12T20:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Awk with sub</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783993#M833551</link>
      <description>Hi Rod, &lt;BR /&gt;&lt;BR /&gt;Thanks for all you help, it was greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 19:58:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-with-sub/m-p/2783993#M833551</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-08-13T19:58:48Z</dc:date>
    </item>
  </channel>
</rss>

