ylafont
April 21st, 2014, 05:03 PM
Forgive my ignorance, I am new to SED and it is not easy to wrap your head around it. I have he following file.
SCANNING: 997750000 (us-hrc:158)
LOCK: none (ss=69 snq=0 seq=0)
SCANNING: 993000000 (us-irc:157, us-cable:157)
LOCK: none (ss=69 snq=0 seq=0)
SCANNING: 991750000 (us-hrc:157)
LOCK: none (ss=70 snq=0 seq=0)
SCANNING: 609000000 (us-irc:88, us-cable:88)
LOCK: qam256 (ss=100 snq=100 seq=100)
TSID: 0x0132
PROGRAM 286: 366 Showtime W (encrypted)
PROGRAM 288: 368 Showtime Showca (encrypted)
PROGRAM 290: 370 Showtime Too W (encrypted)
PROGRAM 292: 372 Showtime Beyond (encrypted)
PROGRAM 294: 374 Showtime Extrem (encrypted)
PROGRAM 302: 386 TMC W (encrypted)
PROGRAM 304: 388 TMC Xtra W (encrypted)
PROGRAM 306: 391 Flix West (encrypted)
PROGRAM 314: 427 Thriller Max We (encrypted)
PROGRAM 356: 409 HBO Comedy West (encrypted)
PROGRAM 358: 411 HBO Zone West (encrypted)
PROGRAM 505: 107 BBC World (encrypted)
SCANNING: 603000000 (us-irc:87, us-cable:87)
LOCK: qam256 (ss=100 snq=100 seq=100)
TSID: 0x0200
PROGRAM 195: 211 MTV 2 (encrypted)
PROGRAM 197: 213 MTV Jams (encrypted)
PROGRAM 198: 214 MTV Hits (encrypted)
PROGRAM 201: 218 VH1 Classics (encrypted)
PROGRAM 202: 219 VH1 Soul (encrypted)
PROGRAM 203: 187 Logo (encrypted)
PROGRAM 207: 222 CMT Pure Countr (encrypted)
PROGRAM 225: 253 Nick Too (encrypted)
PROGRAM 226: 254 Nick Toons (encrypted)
PROGRAM 227: 255 Teen Nick (encrypted)
PROGRAM 324: 273 MTV MUSICA Y MA (encrypted)
PROGRAM 512: 339 Barker 4 - Merc
PROGRAM 513: 0
PROGRAM 514: 500 Barker 6 - Quan
PROGRAM 527: 1508 WAPA TV (encrypted)
I have managed to create the two sed lines that will isolate the frequency (997750000 ) number and the channel listing (512: 339 Barker 4 - Merc) for each frequency.
#!/bin/sh
sed -nr '
s/.*SCANNING: ([0-9]+{6,12}).*/\1/p
s/ \(encrypted\)// ; s/: 0/d ; s/://; s/.*PROGRAM ([0-9]{1,7})+/\1/p
' FileToSearch
I have been playing around without success in trying to store the first line in the buffer and printing along each of the channel listing lines. Ideally, i would like to delete frequencies that do not have channels. Is this possible? or should i be using a different tool?
Final output should look like this
609000000 286 366 Showtime W
609000000 288 368 Showtime Showca
609000000 290 370 Showtime Too W
603000000 195 211 MTV 2
603000000 197 213 MTV Jams
603000000 198 214 MTV Hits
603000000 201 218 VH1 Classics
603000000 202 219 VH1 Soul
603000000 203 187 Logo
SCANNING: 997750000 (us-hrc:158)
LOCK: none (ss=69 snq=0 seq=0)
SCANNING: 993000000 (us-irc:157, us-cable:157)
LOCK: none (ss=69 snq=0 seq=0)
SCANNING: 991750000 (us-hrc:157)
LOCK: none (ss=70 snq=0 seq=0)
SCANNING: 609000000 (us-irc:88, us-cable:88)
LOCK: qam256 (ss=100 snq=100 seq=100)
TSID: 0x0132
PROGRAM 286: 366 Showtime W (encrypted)
PROGRAM 288: 368 Showtime Showca (encrypted)
PROGRAM 290: 370 Showtime Too W (encrypted)
PROGRAM 292: 372 Showtime Beyond (encrypted)
PROGRAM 294: 374 Showtime Extrem (encrypted)
PROGRAM 302: 386 TMC W (encrypted)
PROGRAM 304: 388 TMC Xtra W (encrypted)
PROGRAM 306: 391 Flix West (encrypted)
PROGRAM 314: 427 Thriller Max We (encrypted)
PROGRAM 356: 409 HBO Comedy West (encrypted)
PROGRAM 358: 411 HBO Zone West (encrypted)
PROGRAM 505: 107 BBC World (encrypted)
SCANNING: 603000000 (us-irc:87, us-cable:87)
LOCK: qam256 (ss=100 snq=100 seq=100)
TSID: 0x0200
PROGRAM 195: 211 MTV 2 (encrypted)
PROGRAM 197: 213 MTV Jams (encrypted)
PROGRAM 198: 214 MTV Hits (encrypted)
PROGRAM 201: 218 VH1 Classics (encrypted)
PROGRAM 202: 219 VH1 Soul (encrypted)
PROGRAM 203: 187 Logo (encrypted)
PROGRAM 207: 222 CMT Pure Countr (encrypted)
PROGRAM 225: 253 Nick Too (encrypted)
PROGRAM 226: 254 Nick Toons (encrypted)
PROGRAM 227: 255 Teen Nick (encrypted)
PROGRAM 324: 273 MTV MUSICA Y MA (encrypted)
PROGRAM 512: 339 Barker 4 - Merc
PROGRAM 513: 0
PROGRAM 514: 500 Barker 6 - Quan
PROGRAM 527: 1508 WAPA TV (encrypted)
I have managed to create the two sed lines that will isolate the frequency (997750000 ) number and the channel listing (512: 339 Barker 4 - Merc) for each frequency.
#!/bin/sh
sed -nr '
s/.*SCANNING: ([0-9]+{6,12}).*/\1/p
s/ \(encrypted\)// ; s/: 0/d ; s/://; s/.*PROGRAM ([0-9]{1,7})+/\1/p
' FileToSearch
I have been playing around without success in trying to store the first line in the buffer and printing along each of the channel listing lines. Ideally, i would like to delete frequencies that do not have channels. Is this possible? or should i be using a different tool?
Final output should look like this
609000000 286 366 Showtime W
609000000 288 368 Showtime Showca
609000000 290 370 Showtime Too W
603000000 195 211 MTV 2
603000000 197 213 MTV Jams
603000000 198 214 MTV Hits
603000000 201 218 VH1 Classics
603000000 202 219 VH1 Soul
603000000 203 187 Logo