Here's part of my script:mpv https://www.youtube.com/playlist?list=PLNQL50H--29oy5MOaxEVjcxhX-5Vvskji --shuffle --no-video --input-file=~/.config/mpv/mpv-fifo  > data.txtHere's an example of what's printed to file:Playing: https://www.youtube.com/playlist?list=PLNQL50H--29oy5MOaxEVjcxhX-5VvskjiPlaying: ytdl://a-XXr1H1FeI (+) Audio --aid=1 --alang=eng (*) (vorbis 2ch 44100Hz)AO: [pulse] 44100Hz stereo 2ch floatAll I want is the youtube video id 'a-XXr1H1FeI' - that is after 'Playing: ytdl://'. Each id is one song from a playlist of hundreds and I have several playlists.I would like to have the current song id in a file. This will allow me to grab the song title with youtube-dl and display it with conky. I can also use it to print the id to another file if I skip a song and then later delete the skipped songs from my youtube playlists and so better curate them.I tried the sed and grep solutions from here: Return only the portion of a line after a matching pattern and they would print nothing.I'm using playlists; so this solution: Make mpv display name of youtube link when playing just audio doesn't work.Here's what I've tried to do with sed:This produces nothing.mpv https://www.youtube.com/playlist?list=PLNQL50H--29oy5MOaxEVjcxhX-5Vvskji --shuffle --no-video --input-file=~/.config/mpv/mpv-fifo | sed -n 's~^Playing: ytdl://\(.*\)~\1~p'  > data.txtThis gives me the ids I want, but not until I stop the script. I need them while the songs are playing.mpv https://www.youtube.com/playlist?list=PLNQL50H--29o5FarbAFHBaUNRu2ipp4th --shuffle --no-video --input-file=~/.config/mpv/mpv-fifo > data.txt        sed -n 's~^Playing: ytdl://\(.*\)~\1~p' data.txt > out.txtUpdate:This doesn't actually work but I think it's close.mpv $url --shuffle --no-video --input-file=~/.config/mpv/mpv-fifo > ~/data.txt &    until [ $1 = q ]        do            sed -n 's~^Playing: ytdl://\(.*\)~\1~p' ~/data.txt > ~/out.txt            > ~/data.txt            sleep 5        doneUpdate:It sort of works when I change data.txt > out.txt to ~/data.txt >> ~/out.txt which gives me a list of the ids that have generated, not the single current id. I could work with that I suppose. Also, the loop doesn't seem to stop when $1 = q. I'm not sure what's going on with that. I've found another way to kill the script though.Here's the entire script.I can work with it as is, but it's kind of a kludge. I'll leave it for a couple of days and then call it solved if no one helps.`#! /bin/bashmyfifo=~/.config/mpv/mpv-fifocase $1 in################################### Controlr)  echo add volume 10 > $myfifo        ;;q)  echo stop > $myfifo ; pkill pymp    ;;p)  echo pause > $myfifo        ;;n)  echo playlist-next > $myfifo        ;;l)  echo add volume -10 > $myfifo        ;;################################# Playlists### Sleep & Meditation ###S)  pkill mpv    url=https://www.youtube.com/playlist?list=PLNQL50H--29pkOIBTq6tsWSqdY8ur7Xms        ;;### Epic Trailer Music ###E)  pkill mpv    url=https://www.youtube.com/playlist?list=PLNQL50H--29oy5MOaxEVjcxhX-5Vvskji        ;;### Virtuoso Instrumental Guitar ###G)  pkill mpv    url=https://www.youtube.com/playlist?list=PLNQL50H--29o5FarbAFHBaUNRu2ipp4th    ;;### Old-time Blues ###B)  pkill mpv    url=https://www.youtube.com/playlist?list=PLNQL50H--29pth2mWWKcBQd7YbVClBvea        ;;### Jazz Noir ###J)  pkill mpv    url=https://www.youtube.com/playlist?list=PLNQL50H--29pagSz1i0BG7-30knwiUNXH    ;;### Classic Rock ###R)  pkill mpv    url=https://www.youtube.com/playlist?list=PLNQL50H--29rjmhFC4SqiTQa4jp-NEUN8    ;;esac~/out.txtmpv $url --shuffle --no-video --input-file=~/.config/mpv/mpv-fifo > ~/data.txt &    until [ $1 = q ]        do            sed -n 's~^Playing: ytdl://\(.*\)~\1~p' ~/data.txt >> ~/out.txt            > ~/data.txt            sleep 5        doneexit`
Print youtube video id to file from mpv stdout
awk;sed;grep;youtube dl;mpv