- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to make a loop Extracting items from strin...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2011 04:54 AM
10-21-2011 04:54 AM
Hi
I have lines like this in a file
Server1 Entry1 Entry2 Entry3 ORA9|ORA10|ORA11
Server2 Entry1 Entry2 Entry3 ORA9|ORA11
Server3 Entry1 Entry2 Entry3 ORA8|ORA73|ORA11
Server4 Entry1 Entry2 Entry3 ORA8|ORA73|ORA10
...
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 5 is a set of value with | separator.
Then, How to extract all items to have an output like this
My servers with Oracle 10 are
Server1
Server2
Any idea ?
Best Regards
Den
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2011 05:06 AM
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2011 05:29 AM
10-21-2011 05:29 AM
Re: How to make a loop Extracting items from string
Hi James
In the old version of the HP Forum it was possible to submit points. This is always possible ?
Anyway, thanks for your help.
Best Regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2011 05:37 AM
10-21-2011 05:37 AM
Re: How to make a loop Extracting items from string
Hi James
In fact, this is work.
I have an internal contraint in fact.
I need to extract and test in a loop for each sub item
(I have simplified to much)
I'm able to extract the string where I have sub items. This is easy beacause the position using $5.
Well
in the loop I need to test like this
grep -i subitem $AnotherString and take action depending of the result.
you see ?
Best regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2011 05:38 AM
10-21-2011 05:38 AM
Re: How to make a loop Extracting items from string
@SwissKnife wrote:Hi James
In the old version of the HP Forum it was possible to submit points. This is always possible ?
Anyway, thanks for your help.
Best Regards
Den
Hi Den:
I thought it might be you from your sig!
Yes, in this new community you give "points" with "kudos'. One or more responses or responders can be kudoed by clicking the kudo star next to the person's name.
Marking a post as solved, and giving kudos are separate things (unfortunately). See here for more information:
http://h30499.www3.hp.com/t5/help/faqpage/faq-category-id/kudos#kudos
http://h30499.www3.hp.com/t5/help/faqpage/faq-category-id/solutions#solutions
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2011 05:41 AM
10-21-2011 05:41 AM
Re: How to make a loop Extracting items from string
@SwissKnife wrote:I need to extract and test in a loop for each sub item
(I have simplified to much)
I'm able to extract the string where I have sub items. This is easy beacause the position using $5.
Well
in the loop I need to test like this
grep -i subitem $AnotherString and take action depending of the result.
Hi (again) Den:
As always a description of the problem with sample input and the desired output leads to a solution the quickest. Please provide that.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2011 05:57 AM
10-21-2011 05:57 AM
Re: How to make a loop Extracting items from string
Sorry James, Of course. Here my staff
I have a config file (some lines only)
servers.cfg
LAB Server1 NOALIAS STANDALONE ORA_9|ORA_10
LAB Server2 NOALIAS STANDALONE ORA_9|ORA_11
LAB Server3 NOALIAS STANDALONE ORA_8|ORA_11
LAB Server4 NOALIAS STANDALONE ORA_8|ORA_10
The "|" is for say: (Example) Server1 had Oracle 9 and Oracle 10 installed.
In my script I'm doing something like this:
CONSTRAINT="RAC1 RAC2 FAILOVER STANDALONE ORA_8 ORA11"
okServer=""
cat /home/oracle/automation/rdist.config/servers.cfg |while read line ; do
echo$line
if my line is matching the $CONSTRAINT then I need to add line($2) in my okServer
done
Finaly in my okServer variable I should have only this
echo $okServer
output will be
Server2 Server3 Server4
Thank you James
Best regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2011 06:00 AM
10-21-2011 06:00 AM
Re: How to make a loop Extracting items from string
Yes it's me, when the site has changed I lost my account .... (sic) ;-) But I'm back !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2011 06:52 AM
10-21-2011 06:52 AM
Re: How to make a loop Extracting items from string
Hi (again) Den:
OK see if this meets your needs.
# 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] && print "$F[1]\n"') [ ! -z ${NEW} ] && okServer=$(echo "${okServer} ${NEW}") done < /home/oracle/automation/rdist.config/servers/cfg echo "${okServer}" exit 0
# ./extract
Server2 Server3 Server4
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2011 05:14 AM
10-26-2011 05:14 AM
Re: How to make a loop Extracting items from string
Sorry for the delay. I'm validating your solution. I'll be back soon.
Best Regards
Den