<?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/scripting problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455044#M12205</link>
    <description>I have a pseudo passwd file, encrypted with format:&lt;BR /&gt;&lt;BR /&gt;1:rtesd&lt;BR /&gt;2:refsdcsd&lt;BR /&gt;3:fdcsd&lt;BR /&gt;&lt;BR /&gt;where $2 is to be referenced via $1.  This is the passwd update section of a password retrieval utility for all our boxes.  I want to replace $2 with user entered value ${newpass}.  I have tried using sub() to no avail; could you assist.</description>
    <pubDate>Wed, 18 Oct 2000 13:05:31 GMT</pubDate>
    <dc:creator>Mathais Kashiri</dc:creator>
    <dc:date>2000-10-18T13:05:31Z</dc:date>
    <item>
      <title>awk/scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455044#M12205</link>
      <description>I have a pseudo passwd file, encrypted with format:&lt;BR /&gt;&lt;BR /&gt;1:rtesd&lt;BR /&gt;2:refsdcsd&lt;BR /&gt;3:fdcsd&lt;BR /&gt;&lt;BR /&gt;where $2 is to be referenced via $1.  This is the passwd update section of a password retrieval utility for all our boxes.  I want to replace $2 with user entered value ${newpass}.  I have tried using sub() to no avail; could you assist.</description>
      <pubDate>Wed, 18 Oct 2000 13:05:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455044#M12205</guid>
      <dc:creator>Mathais Kashiri</dc:creator>
      <dc:date>2000-10-18T13:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: awk/scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455045#M12206</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;i can no see what you want.&lt;BR /&gt;Could you post your awk/script to the forum ?&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Wed, 18 Oct 2000 13:08:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455045#M12206</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2000-10-18T13:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: awk/scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455046#M12207</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Suppose you have a file (/tmp/test) with following contents:&lt;BR /&gt;&lt;BR /&gt;1:aaaaaaa&lt;BR /&gt;2:bbbbbbb&lt;BR /&gt;3:ccccccc&lt;BR /&gt;&lt;BR /&gt;And you would like to change &lt;BR /&gt;&lt;BR /&gt;2:bbbbbbb&lt;BR /&gt;&lt;BR /&gt;to &lt;BR /&gt;&lt;BR /&gt;2:fffffff&lt;BR /&gt;&lt;BR /&gt;you can execute the commands:&lt;BR /&gt;&lt;BR /&gt;$ old=$1&lt;BR /&gt;$ new=$newvalue&lt;BR /&gt;$ awk -v new="$new" -v old="$old" '{ sub(old, new); print }' /tmp/test&lt;BR /&gt;&lt;BR /&gt;to obtain the output&lt;BR /&gt;&lt;BR /&gt;1:aaaaaaa&lt;BR /&gt;2:fffffff&lt;BR /&gt;3:ccccccc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this answers your question.&lt;BR /&gt;&lt;BR /&gt;Bye,&lt;BR /&gt;Rik</description>
      <pubDate>Wed, 18 Oct 2000 13:32:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455046#M12207</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2000-10-18T13:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: awk/scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455047#M12208</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Another way:&lt;BR /&gt;&lt;BR /&gt;Given your variables $OLDPW and $NEWPW:&lt;BR /&gt;&lt;BR /&gt;# sed "s/$OLDPW/$NEWPW/" /original_file &amp;gt; /replacement_file&lt;BR /&gt;&lt;BR /&gt;# mv /replacement_file /original_file&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 18 Oct 2000 14:58:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455047#M12208</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-10-18T14:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: awk/scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455048#M12209</link>
      <description>Thanks for all the replies but my problem is still not answered.  I reference via field $1 and change the contents of field $2.  Field number 1 i know, but field number two i do not.</description>
      <pubDate>Wed, 18 Oct 2000 15:08:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455048#M12209</guid>
      <dc:creator>Mathais Kashiri</dc:creator>
      <dc:date>2000-10-18T15:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: awk/scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455049#M12210</link>
      <description>I think this is what you're looking for.....&lt;BR /&gt;&lt;BR /&gt;cat file | awk -v a=$userid -v b=$newpass -FS: '{&lt;BR /&gt;BEGIN {&lt;BR /&gt;   userid = a&lt;BR /&gt;   newpass = b&lt;BR /&gt;}&lt;BR /&gt;if (/^userid/)&lt;BR /&gt;then&lt;BR /&gt;{ print $1:newpass }&lt;BR /&gt;else&lt;BR /&gt;{ print }&lt;BR /&gt;}' &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;The sub function won't work because it replaces only what it's searching for and you want to replace field $2 while keying on $1. Then, just run this and move the result over after the awk runs.&lt;BR /&gt;&lt;BR /&gt;--Scott&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Oct 2000 15:51:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-scripting-problem/m-p/2455049#M12210</guid>
      <dc:creator>Scott D. Allen</dc:creator>
      <dc:date>2000-10-18T15:51:37Z</dc:date>
    </item>
  </channel>
</rss>

