I need to reference the output of this mysql code
mysql -h xx.xx.x.xx -u xxxxxx -pxxxxxx xxxx_xxxx < cmd.sql
that does a count(*) to check if that db table has been filled or not. Trying to grab the return for an if statement later in the script.
I've tried both
count=$(mysql -h xx.xx.x.xx -u xxxxxx -pxxxxxx xxxx_xxxx < cmd.sql)
if [ $count > 0 ]; then
echo "record found\n"
fi
as well as
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
but they both got a "[: count(*): unary operator expected" error.
I even tried to "select count(specific_column) from xxx_xx" with the same error.