[root@192 ~]# ./mysql_Calculator.sh 9 - 2
7
[root@192 ~]# ./mysql_Calculator.sh 9 + 2
11
[root@192 ~]# ./mysql_Calculator.sh 9 \* 2
18
[root@192 ~]# ./mysql_Calculator.sh 9 / 2
4.5000
[root@192 ~]# ./mysql_Calculator.sh 9 % 2
1
[root@192 ~]# cat mysql_Calculator.sh
#!/bin/bash
/usr/bin/mysql -p3306 --socket=/data/3306/mysql.sock -e "select $1 $2 $3;" |awk ‘NR==2{print $0}‘
原文地址:http://wangqh.blog.51cto.com/5367393/1768004