more count_table_count.sh #! /bin/bash >table_count.txt mysql -uroot -p123123 -h192.168.10.100 -e "use rrmj;show tables;"|sed ‘/Tables_in_rrmj/d;/category/d;/duplicate_user/d;/login_user/d;/resource/d;/resource_category_rel/d;/resource_detail/d;/tmp/d;/user/d‘ >tables.txt for table in `cat tables.txt` do echo "$table">>count.txt mysql -uroot -p123123 -h192.168.10.100 -e "use rrmj;select count(*) from $table;">>count.txt done sed -i "/\*/d" count.txt sed -i ‘$!N;s/\n/ /‘ count.txt sort -k 2 -nr count.txt >table_count.txt rm -f count.txt rm -f tables.txt
效果如下截图:
本文出自 “时间煮雨” 博客,请务必保留此出处http://watchman110.blog.51cto.com/9194028/1692848
原文地址:http://watchman110.blog.51cto.com/9194028/1692848