<?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: replace data in a stanza in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109524#M91479</link>
    <description>Thanks for you help again .....&lt;BR /&gt;&lt;BR /&gt;I have used the awk version however the perl and sed would have done the trick.&lt;BR /&gt;&lt;BR /&gt;Chris &lt;BR /&gt;&lt;BR /&gt;:-)</description>
    <pubDate>Tue, 20 May 2008 07:49:00 GMT</pubDate>
    <dc:creator>lawrenzo_1</dc:creator>
    <dc:date>2008-05-20T07:49:00Z</dc:date>
    <item>
      <title>replace data in a stanza</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109520#M91475</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I want to search a file for a sting then change the last field in the last row of that stanza if it doesn't match a string:&lt;BR /&gt;&lt;BR /&gt;this is how the stanza's look:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;usw:&lt;BR /&gt;        shells = /bin/sh,/bin/bsh,/bin/csh,/bin/ksh&lt;BR /&gt;        maxlogins = 3000&lt;BR /&gt;        logintimeout = 60&lt;BR /&gt;        auth_type = STD_AUTH&lt;BR /&gt;&lt;BR /&gt;next stanza: shells = &lt;BR /&gt;             maxlogins = &lt;BR /&gt;             logintimeout =&lt;BR /&gt;             auth_type = STD_AUTH&lt;BR /&gt;&lt;BR /&gt;in this example when the string usw is matched, check the auth_type and replace STD_AUTH with PAM_AUTH.&lt;BR /&gt;&lt;BR /&gt;I have an idea how to do this by removing the stanza completely and then appending the usw stanza to the bottom of the file and changing STD_AUTH with PAM_AUTH.&lt;BR /&gt;&lt;BR /&gt;I am sure there is a more logical way of doing this?&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Mon, 19 May 2008 15:53:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109520#M91475</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2008-05-19T15:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: replace data in a stanza</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109521#M91476</link>
      <description>Shalom Chris,&lt;BR /&gt;&lt;BR /&gt;I think sed may be an answer.&lt;BR /&gt;&lt;BR /&gt;websitename=bsg21.org&lt;BR /&gt;sed s/hpuxconsulting.com/$websitename/g hpuxconsulting.com.virt.conf &amp;gt; $websitename.virt.conf&lt;BR /&gt;&lt;BR /&gt;What this sed sequence does is take a template file hpuxconsulting.com.virt.conf and make a changed copy in this case bsg21.org, the last one I used it on.&lt;BR /&gt;&lt;BR /&gt;It efficiently does a replace and creates a new file with everywhere it sad hpuxconsulting.com now saying bsg21.org&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Mon, 19 May 2008 16:04:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109521#M91476</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2008-05-19T16:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: replace data in a stanza</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109522#M91477</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;Treat each stanza as its own record:&lt;BR /&gt;&lt;BR /&gt;# perl -pe '$/="";if (/^usw/) {s/STD_AUTH/PAM_AUTH/}' file&lt;BR /&gt;&lt;BR /&gt;...of course to update in-place:&lt;BR /&gt;&lt;BR /&gt;# perl -pi.old -e '$/="";if (/^usw/) {s/STD_AUTH/PAM_AUTH/}' file &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 19 May 2008 16:29:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109522#M91477</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-05-19T16:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: replace data in a stanza</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109523#M91478</link>
      <description>Hi (again) Chris:&lt;BR /&gt;&lt;BR /&gt;Oh, if you prefer 'awk' this works analogously ...&lt;BR /&gt;&lt;BR /&gt;#  awk 'BEGIN{RS=""};/^usw/ {sub("STD_AUTH","PAM_AUTH")};{print $0,"\n"}' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 19 May 2008 16:56:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109523#M91478</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-05-19T16:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: replace data in a stanza</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109524#M91479</link>
      <description>Thanks for you help again .....&lt;BR /&gt;&lt;BR /&gt;I have used the awk version however the perl and sed would have done the trick.&lt;BR /&gt;&lt;BR /&gt;Chris &lt;BR /&gt;&lt;BR /&gt;:-)</description>
      <pubDate>Tue, 20 May 2008 07:49:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-data-in-a-stanza/m-p/5109524#M91479</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2008-05-20T07:49:00Z</dc:date>
    </item>
  </channel>
</rss>

