-
Notifications
You must be signed in to change notification settings - Fork 1
/
channel_report.sh
185 lines (165 loc) · 3.25 KB
/
channel_report.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
#set -x
######################################################################################
#
# channel_report.sh
# v2020.07.04.r1
#
# This script will Format the output of the logged data from channel_scan.sh
# available from https://github.com/shmick/TV_Stuff
#
# Use the 'chans' option to generate a list of unique channels found
# Use the 'chanreport' option to output the list sorted by channel
# Use the 'briefchanreport' option to output the list sorted by channel, limited to 12 entries per channel
# or provide a search term ie: date timestamp or channel name
#
# Twitter:// @shmick
#
######################################################################################
Help() {
echo ""
echo "Options are:"
echo ""
echo "last : Display results of the last scan"
echo "chans : Display a list of all channels in the datalog"
echo "chanreport : Display all stats, sorted by channel"
echo "briefchanreport : Similar to chanreport, limited to last 12 results per channel"
echo "lastseen : Display the most recent result of each channel in the datalog"
echo "[search term] : Provide a search term ie: TVO"
echo ""
Usage
}
Usage() {
echo "Usage: $(basename $0) datafile [option]"
echo ""
echo "Use -help for a list of options"
echo ""
exit 1
}
case "$1" in
--help | -help | -h | help)
Help
;;
*)
if [ ! -f "$1" ]; then
Usage
else
DataFile="$1"
fi
;;
esac
Arg2="$2"
case "$3" in
.)
Arg3="."
;;
*)
Arg3="$3"
;;
esac
FindUniqueChans() {
awk -F, '{OFS="\t" ; print $2,$8,$9}' $DataFile | sort -n | uniq
}
GetChannelNames() {
awk -F, '{print $9}' $DataFile | sort -n | uniq
}
OutputWideData() {
awk -F, '{OFS="\t" ; print $1,$2,$3,$4,$5,$6,$7,$8,$9}' $1
}
ResultsCount() {
sort -n -k3 <<<"$results" | grep "$Arg3"
found=$(sort -n -k3 <<<"$results" | grep "$Arg3" | wc -l)
echo ""
echo "$found channels found"
echo ""
}
WideHeader() {
echo ""
# echo -e 'Timestamp\t\tRF\tStrnght\tQuality\tSymbol\tVirtual\tName'
echo -e "Timestamp\t\tRF\tStrngth\tdBmV\tdBm\tQuality\tSymbol\tVirtual\tName"
printf '%.0s-' {1..88}
echo
}
BriefHeader() {
echo -e 'RF\tVirtual\tName'
printf '%.0s-' {1..26}
echo
}
Chans() {
BriefHeader
results=$(FindUniqueChans)
ResultsCount
}
ChanReport() {
for i in $(GetChannelNames); do
WideHeader
grep $i $DataFile | OutputWideData
done
}
FirstSeen() {
results=$(
for i in $(GetChannelNames); do
grep -m 1 $i $DataFile | OutputWideData
done
)
ResultsCount
}
LastSeen() {
results=$(
for i in $(GetChannelNames); do
tac $DataFile | grep -m 1 $i | OutputWideData
done
)
ResultsCount
}
BriefChanReport() {
for i in $(GetChannelNames); do
WideHeader
grep $i $DataFile | OutputWideData | tail -12
done
}
SearchReport() {
WideHeader
results=$(grep -F "$Arg2" $DataFile | OutputWideData)
ResultsCount
}
Last() {
WideHeader
results=$(
Latest=$(tail -1 $DataFile | awk -F, '{print $1}')
tail -50 $DataFile | grep -F "$Latest" | sort -n -t, -k2,2 | OutputWideData
)
ResultsCount
}
ListAllData() {
WideHeader
OutputWideData $DataFile
}
case "$2" in
'chans')
Chans
;;
'last')
Last
;;
'lastseen')
WideHeader
LastSeen
;;
'firstseen')
WideHeader
FirstSeen
;;
'chanreport')
ChanReport
;;
'briefchanreport')
BriefChanReport
;;
--help | -help | -h | help)
Help
;;
*)
SearchReport
;;
esac