<?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: How to make a loop Extracting items from string in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368645#M639655</link>
    <description>&lt;P&gt;Hi (again) Den:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OK see if this meets your needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;# cat ./extract
#!/bin/sh
CONSTRAINT="RAC1 RAC2 FAILOVER STANDALONE ORA_8 ORA_11"
okServer=""
export CONSTRAINT;
while read line
do
    NEW=$(echo ${line}|perl -nae '$ENV{CONSTRAINT}=~$F[4] &amp;amp;&amp;amp; print "$F[1]\n"')
    [ ! -z ${NEW} ] &amp;amp;&amp;amp; okServer=$(echo "${okServer} ${NEW}")
done &amp;lt; /home/oracle/automation/rdist.config/servers/cfg
echo "${okServer}"
exit 0&lt;/PRE&gt;&lt;P&gt;# ./extract&lt;/P&gt;&lt;P&gt;&amp;nbsp;Server2 Server3 Server4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
    <pubDate>Fri, 21 Oct 2011 13:52:11 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2011-10-21T13:52:11Z</dc:date>
    <item>
      <title>How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368551#M639647</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have&amp;nbsp;lines like this in a file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Server1 Entry1 Entry2 Entry3 ORA9|ORA10|ORA11&lt;/P&gt;&lt;P&gt;Server2 Entry1 Entry2 Entry3 ORA9|ORA11&lt;/P&gt;&lt;P&gt;Server3 Entry1 Entry2 Entry3 ORA8|ORA73|ORA11&lt;/P&gt;&lt;P&gt;Server4 Entry1 Entry2 Entry3 ORA8|ORA73|ORA10&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a particular action on Entry5 where I need to manage all sub items (ORAXXX, ......) cheking if the sub item is ORA10 (ORA10 is a parameter of my script). Entry&amp;nbsp;5 is a set of value with | separator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, How to extract all items to have an output like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My servers with Oracle 10 are&lt;/P&gt;&lt;P&gt;Server1&lt;/P&gt;&lt;P&gt;Server2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Den&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 11:54:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368551#M639647</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2011-10-21T11:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368555#M639648</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;# awk '$5~/ORA10/ {print $1}' myfile
Server1
Server4&lt;/PRE&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 12:06:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368555#M639648</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-10-21T12:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368585#M639649</link>
      <description>&lt;P&gt;Hi James&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the old version of the HP Forum it was possible to submit points. This is always possible ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, thanks for your help.&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Den&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 12:29:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368585#M639649</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2011-10-21T12:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368591#M639650</link>
      <description>&lt;P&gt;Hi James&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, this is work.&lt;/P&gt;&lt;P&gt;I have an internal contraint in fact.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to extract and test in a loop for each sub item&lt;/P&gt;&lt;P&gt;(I have simplified to much)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm able to extract the string where I have sub items. This is easy beacause the position using $5.&lt;/P&gt;&lt;P&gt;Well&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in the loop I need to test like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;grep -i subitem $AnotherString and take action depending of the result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you see ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Den&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 12:37:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368591#M639650</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2011-10-21T12:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368593#M639651</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.hpe.com/t5/user/viewprofilepage/user-id/1243189"&gt;@SwissKnife&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Hi James&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the old version of the HP Forum it was possible to submit points. This is always possible ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, thanks for your help.&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Den&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi Den:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought it might be you from your sig!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, in this new community you give "points" with "kudos'.&amp;nbsp; One or more responses or responders can be kudoed by clicking the kudo star next to the person's name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marking a post as solved, and giving kudos are separate things (unfortunately).&amp;nbsp; See here for more information:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://h30499.www3.hp.com/t5/help/faqpage/faq-category-id/kudos#kudos"&gt;http://h30499.www3.hp.com/t5/help/faqpage/faq-category-id/kudos#kudos&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://h30499.www3.hp.com/t5/help/faqpage/faq-category-id/solutions#solutions"&gt;http://h30499.www3.hp.com/t5/help/faqpage/faq-category-id/solutions#solutions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 12:38:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368593#M639651</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-10-21T12:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368595#M639652</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.hpe.com/t5/user/viewprofilepage/user-id/1243189"&gt;@SwissKnife&lt;/a&gt; wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;I need to extract and test in a loop for each sub item&lt;/P&gt;&lt;P&gt;(I have simplified to much)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm able to extract the string where I have sub items. This is easy beacause the position using $5.&lt;/P&gt;&lt;P&gt;Well&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in the loop I need to test like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;grep -i subitem $AnotherString and take action depending of the result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi (again) Den:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As always a description of the problem with sample input and the desired output leads to a solution the quickest.&amp;nbsp; Please provide that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 12:41:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368595#M639652</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-10-21T12:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368611#M639653</link>
      <description>&lt;P&gt;Sorry James, Of course. Here my staff&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a&amp;nbsp;config file (some lines only)&lt;/P&gt;&lt;P&gt;servers.cfg&lt;/P&gt;&lt;P&gt;LAB&amp;nbsp;Server1 NOALIAS&amp;nbsp;&amp;nbsp;STANDALONE&amp;nbsp;ORA_9|ORA_10&lt;BR /&gt;LAB&amp;nbsp;Server2 NOALIAS&amp;nbsp;&amp;nbsp;STANDALONE&amp;nbsp;ORA_9|ORA_11&lt;BR /&gt;LAB&amp;nbsp;Server3 NOALIAS&amp;nbsp;&amp;nbsp;STANDALONE&amp;nbsp;ORA_8|ORA_11&lt;BR /&gt;LAB&amp;nbsp;Server4 NOALIAS&amp;nbsp;&amp;nbsp;STANDALONE&amp;nbsp;ORA_8|ORA_10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "|" is for say: (Example) Server1 had Oracle&amp;nbsp;9 and Oracle 10 installed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In&amp;nbsp;my script I'm doing something like this:&lt;/P&gt;&lt;P&gt;CONSTRAINT="RAC1 RAC2 FAILOVER STANDALONE ORA_8 ORA11"&lt;BR /&gt;okServer=""&lt;/P&gt;&lt;P&gt;cat /home/oracle/automation/rdist.config/servers.cfg |while read line ; do&lt;/P&gt;&lt;P&gt;&amp;nbsp; echo$line&lt;/P&gt;&lt;P&gt;&amp;nbsp; if my line is matching the&amp;nbsp;$CONSTRAINT then I need to add line($2) in my okServer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finaly in my okServer variable&amp;nbsp;I should have only this&lt;/P&gt;&lt;P&gt;echo $okServer&lt;/P&gt;&lt;P&gt;output will be&lt;/P&gt;&lt;P&gt;Server2 Server3 Server4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you James&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Den&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 12:57:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368611#M639653</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2011-10-21T12:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368613#M639654</link>
      <description>&lt;P&gt;Yes it's me, when the site has changed&amp;nbsp;I lost my account .... (sic) ;-) But I'm back !&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 13:00:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368613#M639654</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2011-10-21T13:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368645#M639655</link>
      <description>&lt;P&gt;Hi (again) Den:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OK see if this meets your needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;# cat ./extract
#!/bin/sh
CONSTRAINT="RAC1 RAC2 FAILOVER STANDALONE ORA_8 ORA_11"
okServer=""
export CONSTRAINT;
while read line
do
    NEW=$(echo ${line}|perl -nae '$ENV{CONSTRAINT}=~$F[4] &amp;amp;&amp;amp; print "$F[1]\n"')
    [ ! -z ${NEW} ] &amp;amp;&amp;amp; okServer=$(echo "${okServer} ${NEW}")
done &amp;lt; /home/oracle/automation/rdist.config/servers/cfg
echo "${okServer}"
exit 0&lt;/PRE&gt;&lt;P&gt;# ./extract&lt;/P&gt;&lt;P&gt;&amp;nbsp;Server2 Server3 Server4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 13:52:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5368645#M639655</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-10-21T13:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a loop Extracting items from string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5372653#M639656</link>
      <description>Hi James&lt;BR /&gt;&lt;BR /&gt;Sorry for the delay. I'm validating your solution. I'll be back soon.&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;BR /&gt;Den</description>
      <pubDate>Wed, 26 Oct 2011 12:14:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-a-loop-extracting-items-from-string/m-p/5372653#M639656</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2011-10-26T12:14:46Z</dc:date>
    </item>
  </channel>
</rss>

