This example works well:
if [[ "$(mysql -sse 'USE my_bd; SELECT COUNT(*) FROM my_table" -gt "0" ]]; then echo 1; else echo 0; fi But I need to add a WHERE clause that needs quotes ' inside mysql -e 'query...'
So I need to change the quotes order like this and enclose the mysql -e "query..." with double quotes
I have tried to escape with \"
if [[ "$(mysql -sse \"USE my_bd; SELECT COUNT(*) FROM my_table WHERE my_column = 'something'\"" -gt "0" ]]; then echo 1; else echo 0; fi But that has thrown a bash error
-bash: command substitution: line 21: syntax error near unexpected token `('
I saw other questions about How to escape double quotes in bash? but the answers don't work in my case
$(mysqlgetting closed"$(mysqlto$(mysqlworking good. Bfff I have tried a lot of combinations but not that one. Thank's The bellow answer also work. I need more coffee :)" ", but if the value is expected to be a string, it won't work