Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any suggestions for this type of work...

Status
Not open for further replies.

vptl

Technical User
Jan 22, 2004
120
US
Hello,
I tried to use KSH I am not great at perl...But please suggest if I cannot do this in KSH...

Hi,
Can you pls suggest something for this...

I have a file


Serial ID : 3HY0RV8R



# Vol Emulation Dev Type Mirror Status Cap(MB)
1 1 FBA 0004 Data 1 Ready 8
2 2 FBA 0027 RAID-S Data 1 Ready 8632
8 8 FBA 00A7 RAID-S Data 1 Ready 8632
5 5 FBA 00C7 RAID-S Data 1 Ready 8632
3 3 FBA 0144 RAID-S Parity 2 Ready 8632
6 6 FBA 0187 RAID-S Data 1 Ready 8632

Serial ID : 3HY0RYMR



# Vol Emulation Dev Type Mirror Status Cap(MB)
1 18 FBA 0012 Data 1 Ready 8
10 27 FBA 026F RAID-S Data 1 Ready 8632

And I want to make it like this...(The line# are not consistant and also the SR#)


Serial ID : 3HY0RV8R



# Vol Emulation Dev Type Mirror Status Cap(MB)
3HY0RV8R 1 1 FBA 0004 Data 1 Ready 8
3HY0RV8R 2 2 FBA 0027 RAID-S Data 1 Ready 8632
3HY0RV8R 8 8 FBA 00A7 RAID-S Data 1 Ready 8632
3HY0RV8R 5 5 FBA 00C7 RAID-S Data 1 Ready 8632
3HY0RV8R 3 3 FBA 0144 RAID-S Parity 2 Ready 8632
3HY0RV8R 6 6 FBA 0187 RAID-S Data 1 Ready 8632


Serial ID : 3HY0RYMR



# Vol Emulation Dev Type Mirror Status Cap(MB)
3HY0RYMR 1 18 FBA 0012 Data 1 Ready 8
3HY0RYMR 10 27 FBA 026F RAID-S Data 1 Ready 8632


Serial ID : 3HY0SAZL

Thanks,
 
nawk -f vptl.awk file

Code:
BEGIN {
  FS=":"
}

$1 ~ /Serial/ { sn=$2 ; print; next}

$1 ~ /^[ ]+#/ || $0 ~ /^[ ]*$/ { print; next }

{ print sn, $0 }

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top