<?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: PERL help needed by newbie in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902381#M103244</link>
    <description>Forgot the '-i' option&lt;BR /&gt; &lt;BR /&gt;perl -pi -e 'BEGIN{$p=shift ; $v=shift ;}{s/ .*/ $v/ if /^$p /o}' ParameterName Value file1 file2 ... filen&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Tue, 17 May 2005 16:21:20 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2005-05-17T16:21:20Z</dc:date>
    <item>
      <title>PERL help needed by newbie</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902377#M103240</link>
      <description>After trying to figure this out on my own using the "camel book" over 4 hours and testing, I broke down. I am sure it is a very simple command/commands to accomplish what I am trying to do but I could not acomplish what I wanted to do.&lt;BR /&gt;&lt;BR /&gt;Here is my problem:&lt;BR /&gt;&lt;BR /&gt;I have few files on each of my servers with around a thousand lines in each, from which I need to make a simple search and replace. File format is simple:&lt;BR /&gt;&lt;BR /&gt;ParameterName          Value&lt;BR /&gt;&lt;BR /&gt;where both ParameterName and Value are alphanumeric strings, e.g.,&lt;BR /&gt;&lt;BR /&gt;FilesystemThreshold          92%&lt;BR /&gt;LargefileValue               9999999&lt;BR /&gt;&lt;BR /&gt;what I need to do is to search for the ParameterName and replace the value to a preset string on the same line, but this line may repeat itself multiple times (repetition count varies from one file to the other) in this file and I have to do the replacement on every each occurance of the ParameterName. &lt;BR /&gt;&lt;BR /&gt;What would be a simple one or two liner perl command to accomplish this ?&lt;BR /&gt;&lt;BR /&gt;Thank you for your help.</description>
      <pubDate>Tue, 17 May 2005 12:16:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902377#M103240</guid>
      <dc:creator>exec22</dc:creator>
      <dc:date>2005-05-17T12:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: PERL help needed by newbie</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902378#M103241</link>
      <description>The following thread, with me asking the question contains the perl code you need:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=830280" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=830280&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This one is also useful.&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=780662" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=780662&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Its not breaking down to ask a question. Its efficient use of your time.&lt;BR /&gt;&lt;BR /&gt;Please do not hesitate to ask again.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 17 May 2005 12:20:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902378#M103241</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2005-05-17T12:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: PERL help needed by newbie</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902379#M103242</link>
      <description>&lt;BR /&gt;Why not just use "sed" ??&lt;BR /&gt;&lt;BR /&gt;Here are two ways with sed:&lt;BR /&gt;&lt;BR /&gt;(1) On the command line:&lt;BR /&gt;&lt;BR /&gt;sed -e "s/\(ParameterName1\) \(.*\)/\1 MyAnswer/g" -e "s/\(ParameterName3\) \(.*\)/\1 YourAnswer/g" -e "s/\(ParameterName5\) \(.*\)/\1 TheAnswer/g" ./testparams &amp;gt; NEWFILENAME&lt;BR /&gt;&lt;BR /&gt;(2) Create a file with the parameters that need changing:&lt;BR /&gt;&lt;BR /&gt;vi testvalues&lt;BR /&gt;Add lines like this:&lt;BR /&gt;s/\(ParameterName1\) \(.*\)/\1 MyAnswer/g&lt;BR /&gt;s/\(ParameterName3\) \(.*\)/\1 YourAnswer/g&lt;BR /&gt;s/\(ParameterName5\) \(.*\)/\1 TheAnswer/g&lt;BR /&gt;&lt;BR /&gt;sed -f testvalues ./testparams &amp;gt; NEWFILENAME&lt;BR /&gt;&lt;BR /&gt;Here it is in action (without the redirect output to a new file):&lt;BR /&gt;&lt;BR /&gt;[root@rndspt01 /tmp]# cat testparams                                                                                                                           &lt;BR /&gt;ParameterName1 hello&lt;BR /&gt;ParameterName1 test&lt;BR /&gt;ParameterName2 mom&lt;BR /&gt;ParameterName3 there&lt;BR /&gt;ParameterName4 why&lt;BR /&gt;ParameterName5 This is strange&lt;BR /&gt;ParameterName3 where&lt;BR /&gt;[root@rndspt01 /tmp]# sed -e "s/\(ParameterName1\) \(.*\)/\1 MyAnswer/g" -e "s/\(ParameterName3\) \(.*\)/\1 YourAnswer/g" -e "s/\(ParameterName5\) \(.*\)/\1 TheAnswer/g" ./testparams&lt;BR /&gt;ParameterName1 MyAnswer&lt;BR /&gt;ParameterName1 MyAnswer&lt;BR /&gt;ParameterName2 mom&lt;BR /&gt;ParameterName3 YourAnswer&lt;BR /&gt;ParameterName4 why&lt;BR /&gt;ParameterName5 TheAnswer&lt;BR /&gt;ParameterName3 YourAnswer&lt;BR /&gt;&lt;BR /&gt;OR with the use of a parameter file:&lt;BR /&gt;&lt;BR /&gt;[root@rndspt01 /tmp]# cat testvalues                                                                                                                           &lt;BR /&gt;s/\(ParameterName1\) \(.*\)/\1 MyAnswer/g&lt;BR /&gt;s/\(ParameterName3\) \(.*\)/\1 YourAnswer/g&lt;BR /&gt;s/\(ParameterName5\) \(.*\)/\1 TheAnswer/g&lt;BR /&gt;[root@rndspt01 /tmp]# sed -f ./testvalues ./testparams                                                                                                         &lt;BR /&gt;ParameterName1 MyAnswer&lt;BR /&gt;ParameterName1 MyAnswer&lt;BR /&gt;ParameterName2 mom&lt;BR /&gt;ParameterName3 YourAnswer&lt;BR /&gt;ParameterName4 why&lt;BR /&gt;ParameterName5 TheAnswer&lt;BR /&gt;ParameterName3 YourAnswer&lt;BR /&gt;[root@rndspt01 /tmp]# &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry d brown jr</description>
      <pubDate>Tue, 17 May 2005 13:16:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902379#M103242</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2005-05-17T13:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: PERL help needed by newbie</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902380#M103243</link>
      <description>Run the following one line on each server-&lt;BR /&gt; &lt;BR /&gt;perl -pe 'BEGIN{$p=shift ; $v=shift ;}{s/ .*/ $v/ if /^$p /o}' ParameterName Value file1 file2 ... filen&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 17 May 2005 15:54:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902380#M103243</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-05-17T15:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: PERL help needed by newbie</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902381#M103244</link>
      <description>Forgot the '-i' option&lt;BR /&gt; &lt;BR /&gt;perl -pi -e 'BEGIN{$p=shift ; $v=shift ;}{s/ .*/ $v/ if /^$p /o}' ParameterName Value file1 file2 ... filen&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 17 May 2005 16:21:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902381#M103244</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-05-17T16:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: PERL help needed by newbie</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902382#M103245</link>
      <description>thanks</description>
      <pubDate>Wed, 28 Dec 2005 19:39:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-help-needed-by-newbie/m-p/4902382#M103245</guid>
      <dc:creator>exec22</dc:creator>
      <dc:date>2005-12-28T19:39:41Z</dc:date>
    </item>
  </channel>
</rss>

