I was trying to run following bash line without success, i've tried many variants of the same line without success, hope somebody see the error.

mysql -u user --password=\m\y\p\a\s\s  -h myhost -e 'kill $(mysql -u user --password=\m\y\p\a\s\s -h myhost -e "show processlist;" | grep Waiting | awk '{print $1}' )'

Basically inside $(...) i'm doing a list of processes in status Waiting and outside that code i'm trying to kill such processes, this is a bash question with $() code that is why i'm posting it here, and i guess there is something with quotes, but i don't know how to fix it.


1 Answer 1


Your quotes are too strong.


's are "strong" quotes, which is to say that parameter expansions, subshell expansions, history expansions, and the like do not work within them.

$ echo '$(echo foo)'
$(echo foo)
$ echo "$(echo foo)"

You must log in to answer this question.

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