I have this simple bash script called get-volume.sh
:
mutedStatus=`amixer -c 0 -D pulse get Master | tail -n 1 | grep -c '\[on\]'`
echo $mutedStatus
if "$mutedStatus" -eq 0; then
echo 'x'
else
echo `amixer get Master | awk -F'[]%[]' '/%/ {if ($7 == "off") { print "MM" } else { print $2 }}' | head -n 1`
fi
exit 0
It should
- populate the
mutedStatus
variable with 1 if unmuted and 0 if muted - if muted, echo 'x', else echo the volume
- exit
But when I run the script with bash get-volume.sh
I get this irritating message:
1
get-volume.sh: line 7: 1: command not found
100
why is it giving that error?
It seems to be trying to execute my variable, which is where 1:
comes from, as when I mute my system the message changes to
get-volume.sh: line 7: 0: command not found