Created
January 21, 2022 19:06
-
-
Save adrianmihalko/abd30eb6f3dd458d81b73c80885b52ae to your computer and use it in GitHub Desktop.
Revisions
-
adrianmihalko created this gist
Jan 21, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ If for some reason you got an IPTV playlist which has empty tvg-name, but actual channel names are exists at the end of line, example: #EXTINF:-1 tvg-id="none" tvg-name="none" tvg-logo="" group-title="Testing", Test_Title_CC (GER) #EXTINF:-1 tvg-id="none" tvg-name="none" tvg-logo="" group-title="Testing", Cup Mus (GER) #EXTINF:-1 tvg-id="none" tvg-name="New World (NED)" tvg-logo="" group-title="Apple", New World (NED) you can use awk to fix this issue: awk 'BEGIN{FS=", "}/^#EXTINF:-1/&&/tvg-name="none"/{sub(/tvg-name="none"/,"tvg-name=\x22" $NF "\x22")}{print}' file.txt example output: #EXTINF:-1 tvg-id="none" tvg-name="Test_Title_CC (GER)" tvg-logo="" group-title="Testing", Test_Title_CC (GER) #EXTINF:-1 tvg-id="none" tvg-name="Cup Mus (GER)" tvg-logo="" group-title="Testing", Cup Mus (GER) #EXTINF:-1 tvg-id="none" tvg-name="New World (NED)" tvg-logo="" group-title="Apple", New World (NED)