help needed to get the output from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help needed to get the output from file
# 1  
Old 08-10-2012
help needed to get the output from file

Hi All,

i have a file with below contents (single line) pasted below

HTML Code:
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.grid-pnp.org/2005/11/gpnp-profile gpnp-profile.xsd" ProfileSequence="4" ClusterUId="a412e044b1986f00bfb208e0b89d90bf" ClusterName="lab1-cluster" PALocation=""><gpnp:Network-Profile><gpnp:HostNetwork id="gen" HostName="*"><gpnp:Network id="net1" IP="10.26.208.0" Adapter="en0" Use="public"/><gpnp:Network id="net2" IP="192.168.3.0" Adapter="en1" Use="cluster_interconnect"/><gpnp:Network id="net3" IP="192.168.4.0" Adapter="en2" Use="cluster_interconnect"/></gpnp:HostNetwork></gpnp:Network-Profile><orcl:CSS-Profile id="css" DiscoveryString="+asm" LeaseDuration="400"/><orcl:ASM-Profile id="asm" DiscoveryString="/dev/asmdisk/*" SPFile="+GRID/lab1-cluster/asmparameterfile/registry.253.790951985"/><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> <InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="gpnp orcl xsi"/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>gUWgCm2nA6j9KyTDnM0DHOPy5jw=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>okgwkk8HwHtEIoa708Wdz1d+4P4Q75g3e6bfZr/w0jIOf6yT6dzGquNlZUE/iDvbcdj0LFDRgP2pIr/U+tK2SXw4MicSeSIKWrP8BDn8pCZv7BIzaUW+B6BlqM5HjY34d9/cI0+hDAn5bju1opS2XsTUY3wKmwgP4Jo2v0YMNMo=</ds:SignatureValue></ds:Signature></gpnp:GPnP-Profile>


Whenever Use="Public" need to get the Adaptar=en0 then Use=cluster_interconnect need to get the Adaptar=en1 & en2
Output needed like below

HTML Code:
 Public Adaptar = en0
 Private1 Adaptar = en1
 Private2 Adaptar = en2
Regards
Kannan
# 2  
Old 08-10-2012
This will do the job for your example:
Code:
awk    'BEGIN {RS="/"; FS="[= \"]+"}
     /Adapter/ {
            for (i=NF;i>=1;i--) if ($i=="Adapter") break;
            sub("cluster_interconnect","Private"ct++,$(i+3))
            print $(i+3), "Adapter =", $(i+1)
           }
    ' infile

Code:
public Adapter = en0
Private1 Adapter = en1
Private2 Adapter = en2

This User Gave Thanks to RudiC For This Post:
# 3  
Old 08-10-2012
Thanks a lot !!!! working perfectly
# 4  
Old 08-10-2012
To protect it from changes in the order the adapters occur, try this version:
Code:
awk    'BEGIN {RS="/"; FS="[= \"]+"}
     /cluster_interconnect/ {sub("cluster_interconnect","Private"++ct)}
     /Adapter/ {
            for (i=NF;i>=1;i--) if ($i=="Adapter") break;
            print $(i+3), "Adapter =", $(i+1)
           }
    ' infile

This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Screen Output Needed on every execution

Hi , A shell script being executed by multiple user in a host, but i need the output of each user who executed the script user should have screen output as well ...and unique log file name should generated on execution of script is there anyway to get it below file will overwrite... (5 Replies)
Discussion started by: amar1208
5 Replies

2. Shell Programming and Scripting

Oracle pmon output needed

$ ps -ef | grep pmon | grep -v grep | awk '{ print $8 }' | cut -d '_' -f3 abc1 abc2 abc3 abc4 abc5 +ASM1 Please use code tags from above output i am looking exclude +ASM output and restout put is fine , also when i select any output and if is invalid from above output, shell script... (12 Replies)
Discussion started by: amar1208
12 Replies

3. Shell Programming and Scripting

Help needed in formatting the output

Hi All, Need your help in resolving the below issue. I've a file called "data.txt" with the below lines: TT: <tell://me/sreenivas> <tell://me/100> <tell://me/500> TT: <tell://me/sudheer> <tell://me/300> TT: <tell://me/sreenivas> <tell://me/200> TT:... (6 Replies)
Discussion started by: raosr020
6 Replies

4. Shell Programming and Scripting

Help needed in formatting the Output file

Hi All, Need your help in resolving the below issue. I've a file called "data.txt" with the below lines: TT: <tell://me/sreenivas> <tell://me/100> TT: <tell://me/sudheer> <tell://me/300> TT: <tell://me/sreenivas> <tell://me/200> TT: <tell://me/sudheer> <tell://me/400> ... (3 Replies)
Discussion started by: raosr020
3 Replies

5. Shell Programming and Scripting

Help!! needed to get the desired output

Am in need of your help to get the desired output. nameSECURITY.SERVICES.CONFIG:GETVALUEisPrefetchedNsAccessLast2013-09-13 10:50:13 MESTsAccessTotal1sRunningcHitLastnamePUBLIC.SERVER:INVOKEisPrefetchedNsAccessLast2013-09-17 15:02:05... (5 Replies)
Discussion started by: rocky2013
5 Replies

6. Shell Programming and Scripting

Help needed with file output awk sed command - please

Hi I have a file that contains lines starting with a particular string plus a Colon: I need to output all these lines but only what comes after the colon Can you pelase assist? Example of lines in the file: com.ubs.f35.cashequities/cashequities: 1 2 ... (5 Replies)
Discussion started by: mnassiri
5 Replies

7. UNIX for Dummies Questions & Answers

Grep output help needed

According to linux hardening guide a PATH variable must not contain . or .. so i grep the path variable using. # echo $PATH | grep "." /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin # echo $PATH | grep ".."... (2 Replies)
Discussion started by: pinga123
2 Replies

8. UNIX for Dummies Questions & Answers

Help Needed with Sorting Output

Hi all, I'm using Solaris 10, and need help in sorting the below output from the syslog file in descending rather than ascending order. I would like both the hostname and message columns to be sorted, but right now only the message is sorted and the count column, whose order I would like... (2 Replies)
Discussion started by: wthomas
2 Replies

9. Solaris

showrev output explanation needed

hi this is the output of showrev command from my sun blade 150 machine. bash-3.00# showrev Hostname: u15_9 Hostid: 83685284 Release: 5.10 Kernel architecture: sun4u Application architecture: sparc Hardware provider: Sun_Microsystems Domain: sun.com Kernel version: SunOS 5.10... (1 Reply)
Discussion started by: kingston
1 Replies

10. Shell Programming and Scripting

Output formatting help needed.

Hi guys , I have a file which contains following string.(filename tempdisplay) (location 0.0.0.0:5900) i needed to write a script which will extract the string that comes after 0.0.0.0 i.e the string :5900. I have used following method to extract the string :5900 .Is it a preferred way of... (4 Replies)
Discussion started by: pinga123
4 Replies
Login or Register to Ask a Question

Featured Tech Videos