|
| Hi Everyone,
Need you help to improve on the script i have been using
Raw data:
Client: ssunnbu01
Backup ID: ssunnbu01_1105340684
Policy: Cat_Back
Sched Label: Daily
Schedule Type: FULL (0)
Retention Level: 1 year (8)
Backup Time: Mon Jan 10 2005 15:04:44 (1105340684)
Elapsed Time: 4496 second(s)
Expiration Time: Tue Jan 10 2006 15:04:44 (1136876684)
Kilobytes: 105878474
Number of Files: 409169
Keyword: CAT
Current Script:
BEGIN {OFS=","}
{if (match($0,"^Client:"))
{if (first==0)
first=1
else
print Client,BackupID,Policy,SchedLabel,Schedu
leType,RetentionLevel,BackupDate,BackupT
ime,ElapsedTime,ExpirationDate,Ex
pirationTime,Kilobytes,NumberofFiles,Key
word
Client=$2
BackupID=""
Policy=""
SchedLabel=""
ScheduleType=""
RetentionLevel=""
BackupTime=""
ElapsedTime=""
ExpirationTime=""
Kilobytes=""
Number_of_Files=""
Keyword=""}
if (match($0,"^Client:"))
Client=$2
if (match($0,"^Backup ID:"))
BackupID=$3
if (match($0,"^Policy:"))
Policy=$2
if (match($0,"^Sched Label:"))
SchedLabel=$3
if (match($0,"^Schedule Type:"))
ScheduleType=$3
if (match($0,"^Retention Level:"))
RetentionLevel=$3$4
if (match($0,"^Backup Time:"))
BackupDate=$5"-"$4"-"$6
if (match($0,"^Backup Time:"))
BackupTime=$7
if (match($0,"^Elapsed Time:"))
ElapsedTime=$3
if (match($0,"^Expiration Time:"))
ExpirationDate=$5"-"$4"-"$6
if (match($0,"^Expiration Time:"))
ExpirationTime=$7
if (match($0,"^Kilobytes:"))
Kilobytes=$2
if (match($0,"^Number of Files:"))
NumberofFiles=$4
if (match($0,"^Keyword:"))
Keyword=$2
}' $input > $output
New Raw Data:
Client: server1
Backup ID: server1_1105340684
Policy: Cat_Back
Sched Label: Daily
Schedule Type: FULL (0)
Retention Level: 1 year (8)
Backup Time: Mon Jan 10 2005 15:04:44 (1105340684)
Elapsed Time: 4496 second(s)
Expiration Time: Tue Jan 10 2006 15:04:44 (1136876684)
Kilobytes: 105878474
Number of Files: 409169
Keyword: CAT
ID: UT1565
ID: UT1610
ID: UT1617
ID: UT1619
As you can see new filed "ID" got added and also it is repeating. I added this new patern for matching but only the last occurance of the ID is getting printed where as i need every occurance to be printed and also the number of occurance can vary (min=1 to max= any). Hope you can help
Thanks |
|