Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在shellscript中引用mysql返回_Mysql_Bash_Shell - Fatal编程技术网

在shellscript中引用mysql返回

在shellscript中引用mysql返回,mysql,bash,shell,Mysql,Bash,Shell,我需要引用这个mysql代码的输出 mysql -h xx.xx.x.xx -u xxxxxx -pxxxxxx xxxx_xxxx < cmd.sql 但他们都得到了一个“[:count(*):一元运算符预期”错误 我甚至尝试过“从xxx\U xx中选择计数(特定列)”,但出现了相同的错误。你想要什么 if [ $count -gt 0 ]; then 是输出重定向操作符(类似于谢谢。我知道这是一个问题,但由于错误不在那一行,我没有想到这会是问题所在。它修复了这个错误,但现在我得到了

我需要引用这个mysql代码的输出

mysql -h xx.xx.x.xx -u xxxxxx -pxxxxxx xxxx_xxxx < cmd.sql
但他们都得到了一个“[:count(*):一元运算符预期”错误

我甚至尝试过“从xxx\U xx中选择计数(特定列)”,但出现了相同的错误。

你想要什么

if [ $count -gt 0 ]; then

是输出重定向操作符(类似于
谢谢。我知道这是一个问题,但由于错误不在那一行,我没有想到这会是问题所在。它修复了这个错误,但现在我得到了一个“参数太多”错误。我怀疑是因为mysql命令输出了两行“count(*)| 0”我如何编辑代码以只读取第二行?
count=$(mysql -h xx.xx.x.xx -u xxxxxx -pxxxxxx xxxx_xxxx "select count(*) from xxxx_x")
if [ $count > 0 ]; then
    echo "record found\n"
fi
if [ $count -gt 0 ]; then