pacmd list-sinks | grep -e "index" -e "device.description" outputs:
index: 0 device.description = "GP106 High Definition Audio Controller Digital Stereo (HDMI)" index: 1 device.description = "Built-in Audio Analog Stereo" * index: 2 device.description = "HD 4.40BT"
The default sink starts with
* index:. In the above example I want to output
So the problem-statement is: match
* index and then output the next
device.description that is matched. How can I do that using
EDIT: May be starting with
pacmd list-sinks is the wrong place to start. Is there a better command?
I have something hacky that works:
pacmd list-sinks | grep -Pzo "\* index(.*\n)*" | sed \$d | grep -e "device.description" | cut -f2 -d\"
grep -Pzo "\* index(.*\n)*"outputs all lines after matching
grep -e "device.description"matches the first
cut -f2 -d\"to output only the content.
(However, I am not very pleased as this is ugly! So I will leave the question open for simpler or more elegant solutions.)