Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.42 KB | None | 0 0
  1. awk -F' - |:[0-9]+/' '
  2. FILENAME=="f1" {
  3.    if (/^#EXTINF/) chn=$NF
  4.    if (/^http:/) chg2id[chn] = $NF
  5.    next
  6. }
  7.  
  8. { lines[FNR] = $0 }
  9.  
  10. /^#SERVICE/ { servline = FNR; next }
  11.  
  12. /^#DESCRIPTION/ {
  13.    chn = substr($0,14)
  14.    gsub(/^ +| +$/, "", chn)
  15.    if (chn)  {
  16.       sub( /^#SERVICE 1:(0:)+/, "#SERVICE " chg2id[chn], lines[servline])
  17.    }
  18.    next
  19. }
  20.  
  21. END {
  22.    for (i=1;i<=FNR;++i)
  23.       print lines[i]
  24. }' f1 f2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement