如何发出包含bash脚本中单引号的语句

use*_*338 -1 mysql mysql-python

我尝试在我的一个脚本中执行以下mysql命令:

mysql -e 'show global status like 'open_files''
Run Code Online (Sandbox Code Playgroud)

但它似乎没有用,因为字符串周围有单引号'open_files'.

如何发出包含单引号的命令?

xda*_*azz 6

在外面使用双引号.

mysql -h127.0.0.1 -uxxxxx -pxxxxx -A databasename -e "show global status like 'open_files'"
Run Code Online (Sandbox Code Playgroud)

或者相反的方式:

mysql -h127.0.0.1 -uxxxxx -pxxxxx -A databasename -e 'show global status like "open_files"'
Run Code Online (Sandbox Code Playgroud)

或者你可以逃避单引号.

而你正在使用LIKE,你不是想念野生炭%吗?