You are not logged in.
Pages: 1
I have a bash script and I'm getting this:
status.sh: line 36: [: too many arguments
Here's lines 35 through 37:
music=$(mocp -i | sed -ne 's/^Title: \(.*\)$/\1/p');
[ -z $music ] && music=$(mocp -i | sed -ne 's/File: .*\/\([^ .].*\)$/\1/p')
ptime=$(mocp -i | sed -ne 's/^TimeLeft: //p')
I didn't make this script, this is just for a status bar I'm whipping together. Anyone know why I am getting this error?
Offline
Maybe your $music variable contains whitespace. try wrapping it in quotes:
[ -z "$music" ] ...
Offline
Maybe your $music variable contains whitespace. try wrapping it in quotes:
[ -z "$music" ] ...
Thanks.
Also, I need help getting the volume number. Here's the command I have right now
amixer get PCM | awk '/^ Front Left/ { print $5 }'
But that outputs
[100%]
How can I edit that to make it only say 100, not [100%]?
Offline
String editing is easier with sed:
amixer get Front | sed -ne '/^ Front Left/ s~.*\[\([0-9]*\)%\].*~\1~p'
It can be done with awk though, using the substring function:
amixer get Front | awk '/^ Front Left/ { print substr($5,2,length($5)-3) }'
Offline
Also, I need help getting the volume number. Here's the command I have right now
amixer get PCM | awk '/^ Front Left/ { print $5 }'
But that outputs
[100%]
How can I edit that to make it only say 100, not [100%]?
I like tr myself:
amixer get PCM | awk '/^ Front Left/ { print $5 }' | tr -d [%]
The -d switch makes tr delete characters instead of translating.
Regards.
Offline
Pages: 1