Sponsored Content
Full Discussion: grep options in solaris
Operating Systems Solaris grep options in solaris Post 302694407 by Corona688 on Thursday 30th of August 2012 03:05:50 PM
Old 08-30-2012
Processing XML isn't trivial, grep can't do it. grep handles lines.

Handling XML and non-XML simultaneously is outright odd.

I think I've found a way to at least make your data suitable for an XML parser...

Code:
# Convert mixed xml and non-xml lines into pure XML
$ awk '/INFO/ { sub(/\[/, "", $3); sub(/\]/, "", $6);
        printf("<entry date=\"%s.%s.%s.%s\">\n", $3, $4, $5, $6); next }
        /[/]Main/ { print $0"</entry>" ; next } 1' < log.almostxml

<entry date="29.Aug.2012.13:23:12">
<XML xmlns="http:abc" v="1.0">
    <Main TTm="2011-06-02T13:22:51" BizDt="2011-06-02" TDt="2011-06-02" Cy="GBP" LPx="100.22" LQty="13" EID="89119611243" TTyp="0" TrStat="0" RptTyp="0" TrTyp="0" TID="CLG0000009182268">
        <Hdr SeqNum="1" Snt="2011-06-02T13:22:51" Tb="ABCMESSAGE" TD="ABC" SID="NCM" />
        <Pty R="56" ID="NCM"/>
        <Pty R="11" ID="ABC"/>
        <Instrmt Eh="WARM" SMeth="C" Mult="1250" PxmnMeth="1" MDt="2027-11-26" MY="202711" STp="MAT" PCmplx="FIN" Src="H" HID="STL261127001" Sm="IKL">
            <Pty R="22" ID="NCM"/>
</Main></entry>
<entry date="29.Aug.2012.13:23:12">
<XML xmlns="http:abc" v="1.0">
    <Main TTm="2011-06-02T13:22:51" BizDt="2011-06-02" TDt="2011-06-02" Cy="GBP" LPx="100.22" LQty="13" EID="89119611243" TTyp="0" TrStat="0" RptTyp="0" TrTyp="0" TID="CLG0000009182268">
        <Hdr SeqNum="1" Snt="2011-06-02T13:22:51" Tb="ABCMESSAGE" TD="ABC" SID="NCM" />
        <Pty R="56" ID="NCM"/>
        <Pty R="11" ID="ABC"/>
        <Instrmt Eh="WARM" SMeth="C" Mult="1250" PxmnMeth="1" MDt="2027-11-26" MY="202711" STp="MAT" PCmplx="FIN" Src="H" HID="STL261127001" Sm="IKL">
            <Pty R="22" ID="NCM"/>
</Main></entry>
<entry date="29.Aug.2012.13:23:12">
<XML xmlns="http:abc" v="1.0">
    <Main TTm="2011-06-02T13:22:51" BizDt="2011-06-02" TDt="2011-06-02" Cy="GBP" LPx="100.22" LQty="13" EID="89119611243" TTyp="0" TrStat="0" RptTyp="0" TrTyp="0" TID="CLG0000009182268">
        <Hdr SeqNum="1" Snt="2011-06-02T13:22:51" Tb="ABCMESSAGE" TD="ABC" SID="NCM" />
        <Pty R="56" ID="NCM"/>
        <Pty R="11" ID="ABC"/>
        <Instrmt Eh="WARM" SMeth="C" Mult="1250" PxmnMeth="1" MDt="2027-11-26" MY="202711" STp="MAT" PCmplx="FIN" Src="H" HID="STL261127001" Sm="IKL">
            <Pty R="22" ID="NCM"/>
</Main></entry>
<entry date="29.Aug.2012.13:23:12">
<XML xmlns="http:abc" v="1.0">
    <Main TTm="2011-06-02T13:22:51" BizDt="2011-06-02" TDt="2011-06-02" Cy="GBP" LPx="100.22" LQty="13" EID="89119611243" TTyp="0" TrStat="0" RptTyp="0" TrTyp="0" TID="CLG0000009182268">
        <Hdr SeqNum="1" Snt="2011-06-02T13:22:51" Tb="ABCMESSAGE" TD="ABC" SID="NCM" />
        <Pty R="56" ID="NCM"/>
        <Pty R="11" ID="ABC"/>
        <Instrmt Eh="WARM" SMeth="C" Mult="1250" PxmnMeth="1" MDt="2027-11-26" MY="202711" STp="MAT" PCmplx="FIN" Src="H" HID="STL261127001" Sm="IKL">
            <Pty R="22" ID="NCM"/>
</Main></entry>
<entry date="29.Aug.2012.13:23:12">
<XML xmlns="http:abc" v="1.0">
    <Main TTm="2011-06-02T13:22:51" BizDt="2011-06-02" TDt="2011-06-02" Cy="GBP" LPx="100.22" LQty="13" EID="89119611243" TTyp="0" TrStat="0" RptTyp="0" TrTyp="0" TID="CLG0000009182268">
        <Hdr SeqNum="1" Snt="2011-06-02T13:22:51" Tb="ABCMESSAGE" TD="ABC" SID="NCM" />
        <Pty R="56" ID="NCM"/>
        <Pty R="11" ID="ABC"/>
        <Instrmt Eh="WARM" SMeth="C" Mult="1250" PxmnMeth="1" MDt="2027-11-26" MY="202711" STp="MAT" PCmplx="FIN" Src="H" HID="STL261127001" Sm="IKL">
            <Pty R="22" ID="NCM"/>
</Main></entry>

$

 

8 More Discussions You Might Find Interesting

1. Solaris

changing nfs options on Solaris 10

hi I changed nfs options in "/etc/auto_master": /net -hosts rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,ve rs=3,timeo=600,actimeo=0 then I did automount -v svcadm restart svc:/system/filesystem/autofs svcadm restart svc:/network/nfs/server:default When doing... (2 Replies)
Discussion started by: melanie_pfefer
2 Replies

2. Shell Programming and Scripting

Grep options

Hi Team, I have a list of 12000 files and i am need to search for the names of the file which has long version numbers (say more than 5 decimals).. With the below instance u~15.1.4.1.2.1.5.1.5.1.24.1.24.1.5 lk-l~22.1.3.1.9.1.7.1.24.1.23 YDFVALLN.CPY~1 YEUPCASE.CPY~1 YFPRSTID.CPY~1... (2 Replies)
Discussion started by: ganga.dharan
2 Replies

3. UNIX for Advanced & Expert Users

Problem with grep command options in Sunsolaris

Hi Experts I need the following output from grep command of Sunsolaris on a set of input files. Output:........ 1st search string from file1 2nd search string from file1 3rd search string from file1 1st search string from file2 2nd search string from file2 3rd search string from... (3 Replies)
Discussion started by: ks_reddy
3 Replies

4. Solaris

Solaris Single Sign on options

We are looking for implementing solaris single sign on with AD in our environment which as few hundred Solaris hosts and couple of hundred solaris zones ..IS there any third party software for the same or we can do it by just making the solaris servers as AD clients ? Any help is appreciated. (1 Reply)
Discussion started by: fugitive
1 Replies

5. Solaris

lpadmin command options on solaris 10

lpadmin configuration issues on Solaris 10 Zone. I have configured a print queue using lpadmin command to print to print file server. Source server is a Solaris Zone running Solaris 10. Destination file print server is running OS AIX 5.3. I do not get errors when issuing the lp command to... (0 Replies)
Discussion started by: primeaup
0 Replies

6. UNIX for Dummies Questions & Answers

Grep Options

Hi Folks, I have one query I have a log file to which I reach to putty and I open that particular log file in vi editor and search through /pattern, Suppose I have to search <ProgramId>627857272120951075</ProgramId> Then I have to open abc.log cd /var/log/ ls -ltr vi abc.log... (1 Reply)
Discussion started by: SankalpS
1 Replies

7. UNIX for Dummies Questions & Answers

Exploring the grep options

Hi Folks, I have one query I have a log file to which I reach to putty and I open that particular log file in vi editor and search through /pattern, Suppose I have to search <ProgramId>627857272120951075</ProgramId> Then I have to open abc.log cd /var/log/ ls -ltr vi abc.log... (4 Replies)
Discussion started by: SankalpS
4 Replies

8. Solaris

Available design options for a cluster hosting many different virtualized Solaris versions

Good day, everyone, and thanks first off for reading my question. So, I have been Googling and reading oracle documentation for the past couple weeks, and I am just getting more and more confused as to what I need to do, and I would really appreciate some guidance or at least pointing me to... (4 Replies)
Discussion started by: Lyxix
4 Replies
All times are GMT -4. The time now is 11:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy