Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3405528
  • 博文数量: 534
  • 博客积分: 11595
  • 博客等级: 上将
  • 技术积分: 5785
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-22 17:00
文章分类

全部博文(534)

文章存档

2015年(4)

2014年(27)

2013年(15)

2012年(38)

2011年(36)

2010年(85)

2009年(63)

2008年(142)

2007年(124)

分类: LINUX

2011-12-03 12:22:22

执行:t1.sh phone_num.txt
 
生成文件:
cat a1.txt
select * from t_user_actionlog t where t.visitdate >= to_date('2011-09-01','yyyy-mm-dd') and t.msisdn in (
'13075836025',
'13075836145',
'18606060210')
cat a2.txt
select * from t_user_actionlog t where t.visitdate >= to_date('2011-09-01','yyyy-mm-dd') and t.msisdn in (
'13075836247',
'18605911204',
'13075812112')
cat a3.txt
select * from t_user_actionlog t where t.visitdate >= to_date('2011-09-01','yyyy-mm-dd') and t.msisdn in (
'13110897091',
'13075836149',
'18606999580')
cat a4.txt
select * from t_user_actionlog t where t.visitdate >= to_date('2011-09-01','yyyy-mm-dd') and t.msisdn in (
'18650094591',
'18650094592',
cat t1.sh
#!/bin/awk -f
{
        if(NR%3==1) {
                n++;
                print "select * from t_user_actionlog t where t.visitdate >= to_date('2011-09-01','yyyy-mm-dd') and t.msisdn in (" > "a"n".txt"
        }
        if(NR%3==0)
                print "'"$0"')" >> "a"n".txt";
        else
                print "'"$0"'," >> "a"n".txt";
}
cat phone_num.txt
13075836025
13075836145
18606060210
13075836247
18605911204
13075812112
13110897091
13075836149
18606999580
18650094591
18650094592
阅读(1521) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~