Help with grep - reduce size of channel list

I’m trying to eliminate channels I’m not interested in from my channel list. My IPTV provider produces a m3u file of 18MB, listing channels from countries all over the world. I’ve used grep to reduce that to about 342KB, but there are still too many channels to wade through to find the ones I’m interested in.
Can anyone help me whittle this list down further. I’ve selected by the country codes I’m interested in but I need help in excluding some of these selected channels. For instance I select channels with US, UK and CA, but I’m not interested in channels labeled “US: NHL” and “US: NBA”.

My current grep statement is:
grep -E ‘tvg-name="(US|CA|UK)’ -A 1 /home/osmc/iptvlist/full.m3u |sed “/^–$/d”

A few lines of the (sanitized) input file are:
#EXTINF:-1 tvg-ID=“” tvg-name=“US: TUDN” tvg-logo=“” group-title=“US-Sport”,US: TUDN
#EXTINF:-1 tvg-ID=“” tvg-name=“US: Baby First TV” tvg-logo=“” group-title=“US - Kids”,US: Baby First TV
#EXTINF:-1 tvg-ID=“” tvg-name=“US: NHL Pittsburgh Penguins” tvg-logo=“” group-title=“US-Sport”,US: NHL Pittsburgh Penguins
#EXTINF:-1 tvg-ID=“” tvg-name=“US: NHL Philadelphia Flyers” tvg-logo=“” group-title=“US-Sport”,US: NHL Philadelphia Flyers

Thanks for any suggestions.

I’d suggest asking the IPTV provider.

I don’t think this is an OSMC issue.

You aren’t going to be able to do that in a single grep. You could possible do the original grep, pipe it to a grep -v, so something like:

grep -E ‘tvg-name="(US|CA|UK)’ -A 1 /home/osmc/iptvlist/full.m3u | grep -v "US: NHL" | grep -v "US: NBA" 

may do the trick. That idea could be improved on: I’m just giving you an something to run with.

1 Like

Thanks for the suggestion. I’m just beginning to learn about grep.