Skip to content

Commit 4663d9c

Browse files
authored
Fix output due to addition of dBmV and dBm columns
1 parent 1764061 commit 4663d9c

File tree

1 file changed

+106
-102
lines changed

1 file changed

+106
-102
lines changed

channel_report.sh

+106-102
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
2-
#set -x
2+
#set -x
33
######################################################################################
44
#
5-
# channel_report.sh
6-
# v2014.06.14.r1
5+
# channel_report.sh
6+
# v2020.07.04.r1
77
#
88
# This script will Format the output of the logged data from channel_scan.sh
99
# available from https://github.com/shmick/TV_Stuff
@@ -17,165 +17,169 @@
1717
#
1818
######################################################################################
1919

20-
Help () {
21-
echo ""
22-
echo "Options are:"
23-
echo ""
24-
echo "last : Display results of the last scan"
25-
echo "chans : Display a list of all channels in the datalog"
26-
echo "chanreport : Display all stats, sorted by channel"
27-
echo "briefchanreport : Similar to chanreport, limited to last 12 results per channel"
28-
echo "lastseen : Display the most recent result of each channel in the datalog"
29-
echo "[search term] : Provide a search term ie: TVO"
30-
echo ""
31-
Usage
20+
Help() {
21+
echo ""
22+
echo "Options are:"
23+
echo ""
24+
echo "last : Display results of the last scan"
25+
echo "chans : Display a list of all channels in the datalog"
26+
echo "chanreport : Display all stats, sorted by channel"
27+
echo "briefchanreport : Similar to chanreport, limited to last 12 results per channel"
28+
echo "lastseen : Display the most recent result of each channel in the datalog"
29+
echo "[search term] : Provide a search term ie: TVO"
30+
echo ""
31+
Usage
3232
}
3333

34-
Usage () {
35-
echo "Usage: $(basename $0) datafile [option]"
36-
echo ""
37-
echo "Use -help for a list of options"
38-
echo ""
39-
exit 1
34+
Usage() {
35+
echo "Usage: $(basename $0) datafile [option]"
36+
echo ""
37+
echo "Use -help for a list of options"
38+
echo ""
39+
exit 1
4040
}
4141

4242
case "$1" in
43-
--help|-help|-h|help)
44-
Help
45-
;;
43+
--help | -help | -h | help)
44+
Help
45+
;;
4646
*)
47-
if [ ! -f "$1" ]
48-
then
49-
Usage
50-
else
51-
DataFile="$1"
52-
fi
47+
if [ ! -f "$1" ]; then
48+
Usage
49+
else
50+
DataFile="$1"
51+
fi
52+
;;
5353
esac
5454

5555
Arg2="$2"
5656

5757
case "$3" in
5858
.)
59-
Arg3="."
60-
;;
59+
Arg3="."
60+
;;
6161
*)
62-
Arg3="$3"
62+
Arg3="$3"
63+
;;
6364
esac
6465

65-
FindUniqueChans () {
66-
awk -F, '{OFS="\t" ; print $2,$6,$7}' $DataFile | sort -n | uniq
66+
FindUniqueChans() {
67+
awk -F, '{OFS="\t" ; print $2,$8,$9}' $DataFile | sort -n | uniq
6768
}
6869

69-
GetChannelNames () {
70-
awk -F, '{print $7}' $DataFile | sort -n | uniq
70+
GetChannelNames() {
71+
awk -F, '{print $9}' $DataFile | sort -n | uniq
7172
}
7273

73-
OutputWideData () {
74-
awk -F, '{OFS="\t" ; print $1,$2,$3,$4,$5,$6,$7}' $1
74+
OutputWideData() {
75+
awk -F, '{OFS="\t" ; print $1,$2,$3,$4,$5,$6,$7,$8,$9}' $1
7576
}
7677

77-
ResultsCount () {
78-
sort -n -k3 <<< "$results" | grep "$Arg3"
79-
found=$(sort -n -k3 <<< "$results" | grep "$Arg3" | wc -l)
80-
echo ""
81-
echo "$found channels found"
82-
echo ""
78+
ResultsCount() {
79+
sort -n -k3 <<<"$results" | grep "$Arg3"
80+
found=$(sort -n -k3 <<<"$results" | grep "$Arg3" | wc -l)
81+
echo ""
82+
echo "$found channels found"
83+
echo ""
8384
}
8485

85-
WideHeader () {
86+
WideHeader() {
8687
echo ""
87-
echo -e 'Timestamp\t\tRF\tStrnght\tQuality\tSymbol\tVirtual\tName'
88-
printf '%.0s-' {1..72}; echo
88+
# echo -e 'Timestamp\t\tRF\tStrnght\tQuality\tSymbol\tVirtual\tName'
89+
echo -e "Timestamp\t\tRF\tStrngth\tdBmV\tdBm\tQuality\tSymbol\tVirtual\tName"
90+
printf '%.0s-' {1..88}
91+
echo
8992
}
9093

91-
BriefHeader () {
94+
BriefHeader() {
9295
echo -e 'RF\tVirtual\tName'
93-
printf '%.0s-' {1..26}; echo
96+
printf '%.0s-' {1..26}
97+
echo
9498
}
9599

96-
Chans () {
100+
Chans() {
97101
BriefHeader
98-
results=$(FindUniqueChans)
99-
ResultsCount
102+
results=$(FindUniqueChans)
103+
ResultsCount
100104
}
101105

102-
ChanReport () {
103-
for i in $(GetChannelNames)
104-
do
105-
WideHeader
106-
grep $i $DataFile | OutputWideData
106+
ChanReport() {
107+
for i in $(GetChannelNames); do
108+
WideHeader
109+
grep $i $DataFile | OutputWideData
107110
done
108111
}
109112

110-
FirstSeen () {
111-
results=$(
112-
for i in $(GetChannelNames)
113-
do
114-
grep -m 1 $i $DataFile | OutputWideData
115-
done)
113+
FirstSeen() {
114+
results=$(
115+
for i in $(GetChannelNames); do
116+
grep -m 1 $i $DataFile | OutputWideData
117+
done
118+
)
116119
ResultsCount
117-
}
118-
119-
LastSeen () {
120-
results=$(
121-
for i in $(GetChannelNames)
122-
do
123-
tac $DataFile | grep -m 1 $i | OutputWideData
124-
done)
120+
}
121+
122+
LastSeen() {
123+
results=$(
124+
for i in $(GetChannelNames); do
125+
tac $DataFile | grep -m 1 $i | OutputWideData
126+
done
127+
)
125128
ResultsCount
126-
}
129+
}
127130

128-
BriefChanReport () {
129-
for i in $(GetChannelNames)
130-
do
131-
WideHeader
132-
grep $i $DataFile | OutputWideData | tail -12
131+
BriefChanReport() {
132+
for i in $(GetChannelNames); do
133+
WideHeader
134+
grep $i $DataFile | OutputWideData | tail -12
133135
done
134136
}
135137

136-
SearchReport () {
138+
SearchReport() {
137139
WideHeader
138140
results=$(grep -F "$Arg2" $DataFile | OutputWideData)
139141
ResultsCount
140142
}
141143

142-
Last () {
144+
Last() {
143145
WideHeader
144-
results=$(
145-
Latest=$(tail -1 $DataFile | awk -F, '{print $1}')
146-
tail -50 $DataFile | grep -F "$Latest" | sort -n -t, -k2,2 | OutputWideData )
146+
results=$(
147+
Latest=$(tail -1 $DataFile | awk -F, '{print $1}')
148+
tail -50 $DataFile | grep -F "$Latest" | sort -n -t, -k2,2 | OutputWideData
149+
)
147150
ResultsCount
148151
}
149152

150-
ListAllData () {
153+
ListAllData() {
151154
WideHeader
152155
OutputWideData $DataFile
153156
}
154157

155158
case "$2" in
156159
'chans')
157-
Chans
158-
;;
160+
Chans
161+
;;
159162
'last')
160-
Last
161-
;;
163+
Last
164+
;;
162165
'lastseen')
163-
WideHeader
164-
LastSeen
165-
;;
166+
WideHeader
167+
LastSeen
168+
;;
166169
'firstseen')
167-
WideHeader
168-
FirstSeen
169-
;;
170+
WideHeader
171+
FirstSeen
172+
;;
170173
'chanreport')
171-
ChanReport
172-
;;
174+
ChanReport
175+
;;
173176
'briefchanreport')
174-
BriefChanReport
175-
;;
176-
--help|-help|-h|help)
177-
Help
178-
;;
177+
BriefChanReport
178+
;;
179+
--help | -help | -h | help)
180+
Help
181+
;;
179182
*)
180-
SearchReport
183+
SearchReport
184+
;;
181185
esac

0 commit comments

Comments
 (0)