- 论坛徽章:
- 0
|
自己写了一个shell程序,想生成报表,但在报表格式上有点问题。报表是生成了,但是每一列不对齐,请教用什么命令使它们对齐?非常感谢!
这是SHELL程序
# !/bin/bash
# author: jackdong
# date: 2005-10-12
# funcion: oneside
# last modi:2005-10-20
starttime=$1
endtime=$2
echo -n "please input starttime:"
echo "For Example: 2005-09-01"
read starttime
echo -n "please input endtime:"
echo "For Example: 2005-09-30"
read endtime
yy_mm=`date --date='1 month ago' +"%Y/%m"`
bdblogin="admin/admin123"
cdblogin="administrator/admin123"
echo -e \
"set wrap off;\n" \
"set linesize 32767;\n" \
"set pagesize 0;\n" \
"select 123 || '%' || b.account_no || '%' || d.name || '%' || count(c.cdr_serial) || '%' || sum(c.duration) || '%' || sum(c.dura
tion*rate) " \
"from admin.comp_account b, administrator.cdr c, admin.company d where call_type='8' and c.comp_serial=b.comp_acc_serial " \
"and c.comp_serial=d.comp_acc_serial and b.comp_acc_serial=d.comp_acc_serial and " \
" to_date(substr(start_time,0,10), 'yyyy-mm-dd') >;= to_date('$starttime', 'yyyy-mm-dd') " \
"and to_date(substr(start_time,0,10), 'yyyy-mm-dd') <= to_date('$endtime', 'yyyy-mm-dd') " \
"group by b.account_no,d.name order by d.name;" | \
sqlplus -S $cdblogin | \
awk -F% '/^[0-9]*%/{printf("%s\t %s\t %s\t %s\t %s\t\n", $2,$3,$4,$5,$6)}' >; tmp_loc.txt
echo -e "\t\tReport on Unsuccessful or One sided Smart Dialler Calls \n">;cdr_oneside.txt
echo -e "I SG \t\t\t\t Date: "$yy_mm"\n">;>;cdr_oneside.txt
echo -e "Voice Reference Number\tAcct Name\tNo of One-side Calls\tTotal Duration of One-side Calls\tTotal Costs of One-side Calls\n"
>;>;cdr_oneside.txt
cat tmp_loc.txt | awk -F% '{printf("%s\n", $1,$2,$3,$4,$5)}' >;>;cdr_oneside.txt
#echo -e "Report is sorted alphabetically by the Destination Name">;>;cdr_oneside.txt
rm -rf tmp_loc.txt
这是运行的结果:
Report on Unsuccessful or One sided Smart Dialler Calls
PI SG Date: 2005/09
Voice Reference Number Acct Name No of One-side Calls Total Duration of One-side Calls Total Costs of One-side Call
s
0001-000-000 Acxellence Pte Ltd 21 21.6 2.224
0176-000-000 Emsley Pte Ltd 44 18.2 6.903
0549-000-000 Eye-Biz Pte Ltd 8 2.9 .725
0545-000-000 Hoestar Inspection International Pte Ltd 2 .4 .14
0539-000-000 LSK Engineering (S) Pte Ltd 1 .2 .118
0542-000-000 Murtaza Yunus 3 .7 .455
0547-000-000 NTA (S) Holdings Pte Ltd 3 .5 .175
0181-000-000 Now2call 13 13 1.04
0102-000-000 Sea Ocean Marine Products Pte Ltd 1 .2 .1
0551-000-000 Southern Printing & Publishing Co Pte Ltd 2 .4 .14
0541-000-000 Xenith Solutions Pte Ltd 9 1.5 .75
0470-000-000 chris test 1 11 11 .88
0092-000-000 testing 1 .2 .078 |
|