0

I have following command:

usb_soundcard_sink=$(pactl list short sinks | grep "alsa_output" | awk '{ print $2 }' | tail -n1)

It find the sinks name:

sink_index=$(pactl list short sinks | awk -v index_number=$usb_soundcard_sink '$2==index_number {print $1}')

It find the index number of given sinks i.e $usb_soundcard_sink

Now in the following command I want to pass the $sink_index as parameter.

I tried in the following command:

volume=$(pactl list sinks | perl -000ne 'if(/#$sink_index/){/(Volume:.*)/; print "$1\n"}' | sed 's/.*\ \(.*\)%.*/\1/g')

But it is not accepted $sink_index as parameter.

So how can i pass the value of sink_index variable to that command?

1 Answer 1

1

If you stored sink_index as environment variable you could use $ENV{} instead:

export sink_index=$(pactl list short sinks | awk -v index_number=$usb_soundcard_sink '$2==index_number {print $1}')

volume=$(pactl list sinks | perl -000ne 'if(/#$ENV{sink_index}/){/(Volume:.*)/; print "$1\n"}' | sed 's/.*\ \(.*\)%.*/\1/g')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .