filtering out certain output | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

filtering out certain output

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-04-2012
prodigy06 prodigy06 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 10 October 2012, 5:36 AM EDT
Posts: 19
Thanks: 8
Thanked 0 Times in 0 Posts
filtering out certain output

hi guys, i have a long output and cant figure out a flexible way to show the meta members from a device. please help. some device have 2,4 or 8 meta members but for this example i have 4 meta members, what is a flexible way to pull them out from this output? need your inputs thanks.


Code:
    Device Physical Name     : Not Visible

    Device Symmetrix Name    : 6AD2
    Device Serial ID         : N/A
    Symmetrix ID             : ****

    Device Group Name        : billyd3-snap1
    Device Logical Name      : D-data1

    Number of RAID Groups    : 0

    Attached BCV Device      : N/A

    Attached VDEV TGT Device : N/A

    Vendor ID                : EMC
    Product ID               : SYMMETRIX
    Product Revision         : 5875
    Device WWN               : ****
    Device Emulation Type    : FBA
    Device Defined Label Type: N/A
    Device Defined Label     : N/A
    Device Sub System Id     : 0x0060
    Cache Partition Name     : DEFAULT_PARTITION
    Bound Thin Pool Name     : 1000_7K_P1

    Device Block Size        : 512

    Device Capacity
        {
        Cylinders            :     131072
        Tracks               :    1966080
        512-byte Blocks      :  251658240
        MegaBytes            :     122880
        KiloBytes            :  125829120
        }

    Device External Identity
        {
        Device WWN           : ****

        Front Director Paths (4):
            {
            -----------------------------------
             DIRECTOR   PORT             LUN
            ----------  ---- -------- ---------
            Type Num    Sts  VBUS TID SYMM Host
            -----------------------------------
            FA   03F:0  RW   000  00  024  N/A
            FA   03F:1  RW   000  00  024  N/A
            FA   04F:0  RW   000  00  024  N/A
            FA   04F:1  RW   000  00  024  N/A
            }

        Geometry             : Native
            {
            Sectors/Track        :        128
            Tracks/Cylinder      :         15
            Cylinders            :     131072
            512-byte Blocks      :  251658240
            MegaBytes            :     122880
            KiloBytes            :  125829120
            }
        }

    Device Configuration     : TDEV            (Meta Head)

    Device is WORM Enabled   : No
    Device is WORM Protected : No

    SCSI-3 Persistent Reserve: Disabled

    Dynamic Spare Invoked    : No

    Dynamic RDF Capability   : RDF1_OR_RDF2_Capable

    STAR Mode                : No
    STAR Recovery Capability : None
    STAR Recovery State      : NA

    Device Service State     : Normal

    Device Status            : Ready            (RW)
    Device SA Status         : Ready            (RW)
    Device User Pinned       : FALSE
    Host Access Mode         : ACTIVE

    Extent Based Clone       : None

    Front Director Paths (4):
        {
        ----------------------------------------------------------------------
                                 POWERPATH  DIRECTOR   PORT             LUN
                                 --------- ----------  ---- -------- ---------
        PdevName                 Type      Type Num    Sts  VBUS TID SYMM Host
        ----------------------------------------------------------------------
        Not Visible              N/A       FA   03F:0  RW   000  00  024  N/A
        Not Visible              N/A       FA   03F:1  RW   000  00  024  N/A
        Not Visible              N/A       FA   04F:0  RW   000  00  024  N/A
        Not Visible              N/A       FA   04F:1  RW   000  00  024  N/A
        }

    Meta Configuration       : Concatenated
    Meta Device Members (4)  :
        {
        ----------------------------------------------------------------------
                               BCV  DATA                    RDF  DATA
                      ----------------------------  --------------------------
        Sym    Cap    Std Inv BCV Inv Pair          R1 Inv R2 Inv Pair
        Dev    (MB)   Tracks  Tracks  State         Tracks Tracks State
        ----------------------------------------------------------------------
    --> 6AD2  30720        -       -  N/A                -      - N/A
        6AD3  30720        -       -  N/A                -      - N/A
        6AD4  30720        -       -  N/A                -      - N/A
        6AD5  30720        -       -  N/A                -      - N/A
        ----------------------------------------------------------------------
             122880        -       -                     -      -
        }

from this long output i just need:

Code:
6AD2 
6AD3  
6AD4  
6AD5

and append it with this so my desired final output would be:


Code:
delete dev 6AD2;
delete dev 6AD3;
delete dev 6AD4;
delete dev 6AD5;

thanks a lot in advance.
Sponsored Links
    #2  
Old 10-04-2012
agama agama is offline Forum Advisor  
Always Learning
 
Join Date: Jul 2010
Last Activity: 7 April 2014, 3:02 PM EDT
Location: earth>US>UTC-5
Posts: 1,466
Thanks: 110
Thanked 506 Times in 485 Posts
Have a go with this:


Code:
awk '
    /----/ { next; }
    /Meta Device Members/ {
        snarf = 1;
        split( $(NF-1), a, "(" );
        n = a[2]+0;
        next;
    }

    snarf == 1 && $1 == "Dev" { snarf = 2; next; }

    n > 0 && snarf > 1 {
        gsub( "-->", "" );
        n--;
        printf( "delete dev %s\n", $1 );
        next;
    }
' input-file

Sponsored Links
    #3  
Old 10-05-2012
prodigy06 prodigy06 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 10 October 2012, 5:36 AM EDT
Posts: 19
Thanks: 8
Thanked 0 Times in 0 Posts
do you mean to do it like this?


Code:
DEV=$1

symdg show $DEV -sid 123 >> showdev.txt

awk '
    /----/ { next; }
    /Meta Device Members/ {
        snarf = 1;
        split( $(NF-1), a, "(" );
        n = a[2]+0;
        next;
    }

    snarf == 1 && $1 == "Dev" { snarf = 2; next; }

    n > 0 && snarf > 1 {
        gsub( "-->", "" );
        n--;
        printf( "delete dev %s\n", $1 );
        next;
    }
' showdev.txt

its giving out

awk: syntax error near line 13
awk: illegal statement near line 13

---------- Post updated at 12:57 PM ---------- Previous update was at 12:33 PM ----------

i just thought about it, but cant translate it into commands, we can grep out '
Meta Device Members (4) :
then use the number 4 to increment the user input device id which is in hex form. in this scenario

6AD2 6AD3 6AD4 6AD5
    #4  
Old 10-05-2012
pamu pamu is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 1 July 2014, 5:40 AM EDT
Posts: 1,649
Thanks: 58
Thanked 478 Times in 474 Posts
try something like this...

Code:
awk '/Meta Configuration/{a=1}
a==1 {if ($0 ~ /[0-9]/ && b > 2){gsub("-->","",$0);print "delete dev "$1";"}else if($0 ~ /-----/){b++}}
b==4{a=0}' file

Sponsored Links
    #5  
Old 10-05-2012
itkamaraj's Avatar
itkamaraj itkamaraj is offline Forum Advisor  
^Kamaraj^
 
Join Date: Apr 2010
Last Activity: 16 July 2014, 11:41 PM EDT
Posts: 3,057
Thanks: 33
Thanked 657 Times in 636 Posts

Code:
 
$ nawk '/Meta Device Members/{gsub("[()]","",$4);a=8+$4;for(i=1;i<a;i++){getline;if(i>=8)print "delete dev ",$(NF-7)}}' input.txt
delete dev  6AD2
delete dev  6AD3
delete dev  6AD4
delete dev  6AD5

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
filtering and formatting the output kamauv234 Shell Programming and Scripting 4 09-27-2012 08:46 PM
Filtering jamie_123 Shell Programming and Scripting 1 06-13-2012 05:01 AM
filtering print output linuxgeek Shell Programming and Scripting 2 04-14-2011 02:47 AM
filtering and sending sar output via email noorm Shell Programming and Scripting 3 01-19-2010 07:29 AM
filtering a range of ports out of a netstat output marcpascual Shell Programming and Scripting 1 09-30-2008 09:36 PM



All times are GMT -4. The time now is 01:27 PM.