-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhadrgrab.pl
executable file
·66 lines (47 loc) · 1.39 KB
/
hadrgrab.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl
##########################################
# Copyright ? 2023 Jun Su Lee. All rights reserved.
# Author : Jun Su Lee ( [email protected] )
# Description : to grab lines of multiple db2pd -hadr output
#
# Category : DB2 support
# Usage
# ./hadrgrab.pl -f='filename' -p='functionname'
# -p : pattern string
# Date : 04.May, 2023
#
# Revision History
# - Nov. 30, 2018 :
##########################################
use Getopt::Long;
my $DEBUG=1;
my @fileList; ## Input file name list
my $fileName; ## Input file name : command line option
## js_split_snapshot.pl -i='MPSBODB.snapshot.*'
GetOptions (
'f=s' => \$fileName, # Filename to read
'p=s' => \$grabPattern, # pattern to grab
)
or die "Incorrect Usage ! \n";
# get file list
@fileList = glob($fileName);
sub doGrabWork {
my ( $fn ) = @_ ;
open FH, $fn or die ;
print " \n############### Processing file : $fn \n\n";
while ( <FH> ) {
#print $_;
if ( m/^Database\s.+Date\s(.+)$/ ) {
$fileTimeStamp = $1;
print "$fileTimeStamp " ;
}
#print "$grabPattern \n";
if ( m/$grabPattern/ ) {
print $_;
}
}
}
foreach my $inputFile ( @fileList ) {
doGrabWork $inputFile;
print "\n";
}