Basically I want to be able to invoke a given command, in this case mysql -uanon -ppwd -db mydb -e "select count(*) from table1"
. And then take this commands result (the count on that table) and place it in a variable in bash script. What is the simplest way to achieve this?
相关问题
- How to get the return code of a shell script in lu
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- JQ: Select when attribute value exists in a bash a
In other words, use the $() syntax.
You most likely want to use batch mode (-B) and disable column names (--disable-column-names) for non-interactive mysql output: