-
Notifications
You must be signed in to change notification settings - Fork 20
/
show_log_ranges.sh
executable file
·49 lines (42 loc) · 1015 Bytes
/
show_log_ranges.sh
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
#!/bin/sh
#
# Lists start and end of each log file
#
# Author Mark Curtis, 2015 Jul 08
#
# Enter your date string here
searchStr="2015-"
function checkForFiles {
# validate we can find at least 1 file
files=$(find . -name "$1" -type f)
# check if no files found
if [ -z "$files" ]
then
echo "Couldn't find any files named $1 from here. Exiting"
exit 1
fi
# get the first directory
for file in $files
do
node0=$file
break
done
}
# Check for the files first
checkForFiles system.log
# validate we can find at least 1 file
if [ -r $node0 ]
then
# at least 1 file is readable
echo "===== `basename $0` ====="
else
echo "USAGE - Please run script in the nodes directory of a Diagnostics Report"
exit 1
fi
# iterate through all logs
for logfile in $files
do
grep -H $searchStr $logfile | head -1 | awk '{print $1,"Start",$4, $5}'
grep -H $searchStr $logfile | tail -1 | awk '{print $1, "End",$4, $5}'
echo ""
done