<?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: Changing file contents using script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-file-contents-using-script/m-p/3303323#M881069</link>
    <description>&lt;BR /&gt;userid="user1"&lt;BR /&gt;uperms=2&lt;BR /&gt;&lt;BR /&gt;if (( $uperms &amp;gt; -1 &amp;amp;&amp;amp; $uperms &amp;lt; 5 )) ;then&lt;BR /&gt;ex -s -c "s/\(^$userid:.*:\)[0-4]/\1$uperms/ |wq" yourfile&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;you might want to make a back up copy of your file before making your modification just in case</description>
    <pubDate>Sat, 12 Jun 2004 12:40:24 GMT</pubDate>
    <dc:creator>curt larson_1</dc:creator>
    <dc:date>2004-06-12T12:40:24Z</dc:date>
    <item>
      <title>Changing file contents using script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-file-contents-using-script/m-p/3303320#M881066</link>
      <description>Hi, &lt;BR /&gt;i have a file containing 4 feilds separated by a : . This is used by application to determine the usrer rights. File look like this&lt;BR /&gt;&lt;BR /&gt;user1:lp:3:FLb//*xKns:&lt;BR /&gt;user3:lp:0:ClbkWTlqmYY:&lt;BR /&gt;user4:lp:3:OyNWlqPZxxE:&lt;BR /&gt;user5:lp:4:XyyNpqrzT/K:&lt;BR /&gt;&lt;BR /&gt;The same file existing in almost 200 systems running HP-UX 11i. Now requirement is to change the user rights in feild 3. The number varies from 0 - 4. How can i achieve this using a script. Any help is highly appriciated.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;...Jag</description>
      <pubDate>Sat, 12 Jun 2004 05:11:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-file-contents-using-script/m-p/3303320#M881066</guid>
      <dc:creator>jagdeesh</dc:creator>
      <dc:date>2004-06-12T05:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Changing file contents using script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-file-contents-using-script/m-p/3303321#M881067</link>
      <description>in my opinion, but I'm probably a bit prejusiced, Perl is the obvious choise&lt;BR /&gt;&lt;BR /&gt;# perl -pi -aF: -e'$F[2]++;$_=join":",@F' your_file&lt;BR /&gt;&lt;BR /&gt;to increment all third fields (perl counts from 0)&lt;BR /&gt;&lt;BR /&gt;# perl -pi -aF: -e'$F[0]=~/9/ and $F[2]=9;$_=join":",@F' your_file&lt;BR /&gt;&lt;BR /&gt;to set field 3 to 9 if the first field has a 9 in it&lt;BR /&gt;&lt;BR /&gt;# perl -pi -aF: -e'$F[0]=~/6$/ and $F[2]+=4;$_=join":",@F' your_file&lt;BR /&gt;&lt;BR /&gt;to add 4 to field 3 if the first field ends with a 6&lt;BR /&gt;&lt;BR /&gt;# perl -pi -aF: -e'BEGIN{%u=(user2=&amp;gt;4,user8=&amp;gt;3)}exists$f{$F[0]} and $F[2]=$u{$F[0]};$_=join":",@F' your_file&lt;BR /&gt;&lt;BR /&gt;to set field 3 to 4 for field1 equal to user2, field 3 to 3 for field1 equal to user8, and field 3 unchanged for all other users&lt;BR /&gt;&lt;BR /&gt;Due to the -pi option, all changes are in-place, meaning there are no pipes or temporary files involved&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn&lt;BR /&gt;</description>
      <pubDate>Sat, 12 Jun 2004 05:53:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-file-contents-using-script/m-p/3303321#M881067</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-06-12T05:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Changing file contents using script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-file-contents-using-script/m-p/3303322#M881068</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can try with awk as well:&lt;BR /&gt;&lt;BR /&gt;TMP=/tmp/$$&lt;BR /&gt;awk -F: {$3=whatyouneed;print}' $SOURCE |sed 's/ /:/g'&amp;gt;$TMP&lt;BR /&gt;cp $TMP $SOURCE&lt;BR /&gt;&lt;BR /&gt;Naturally, you will have to define the variable "whatyouneed" according to your needs.&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Sat, 12 Jun 2004 06:26:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-file-contents-using-script/m-p/3303322#M881068</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2004-06-12T06:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Changing file contents using script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-file-contents-using-script/m-p/3303323#M881069</link>
      <description>&lt;BR /&gt;userid="user1"&lt;BR /&gt;uperms=2&lt;BR /&gt;&lt;BR /&gt;if (( $uperms &amp;gt; -1 &amp;amp;&amp;amp; $uperms &amp;lt; 5 )) ;then&lt;BR /&gt;ex -s -c "s/\(^$userid:.*:\)[0-4]/\1$uperms/ |wq" yourfile&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;you might want to make a back up copy of your file before making your modification just in case</description>
      <pubDate>Sat, 12 Jun 2004 12:40:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-file-contents-using-script/m-p/3303323#M881069</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-06-12T12:40:24Z</dc:date>
    </item>
  </channel>
</rss>

