mysql联表查询脚本:
1
2
3
4
5
|
#!/bin/sh
kkmailmysqlpass=$(
cat
/usr/local/kk-mail/config/custom
.conf |
grep
-w
"pass"
|
awk
-F
" "
'{print $NF}'
)
/usr/local/kk-mail/service/mysql/bin/mysql
-u kkmail -p$kkmailmysqlpass kkmail -e
"select b.realname,a.mailbox,a.quota_mailbox,a.quota_netdisk,a.limit_send,a.limit_recv,c.position,d.title from core_mailbox a,co_user b,co_department_member c,co_department d where a.mailbox_id=b.mailbox_id and a.mailbox_id=c.mailbox_id and c.dept_id=d.id;"
>
/root/user
.txt
awk
'BEGIN{OFS="\t"} {if($5==-1){$5="不限制"}if($5==1){$5="禁止"}if($5==2){$5="本域"}if($5==3){$5="指定外域"}if($5==4){$5="本地所有域"}if($6==-1){$6="不限制"}if($6==1){$6="禁止"}if($6==2){$6="本域"}if($6==3){$6="指定外域"}if($6==4){$6="本地所有域"}print}'
/root/user
.txt >
/root/user2
.txt
cat
user2.txt |
sed
1d |
sed
'1i\姓名 邮箱 容量 网盘 发送 接收 职位 部门'
>
/root/user3
.txt
|
本文转自 sailikung 51CTO博客,原文链接:http://blog.51cto.com/net881004/2072698,如需转载请自行联系原作者