1 在linux环境下进行处理linux
1.1.对文件的第一行以前插入一行sql
sed '1 i\phone_num,phone_cishu,phone_shichang' -i xuzhou_manyou.txt sed '1 i\本地号码,通话次数,通话时长(分钟)' -i xuzhou_manyou.txt
1.2.删除文件中第一行shell
sed -i '1 d' xuzhou_manyou.txt
1.3.对文件中第二行按数字大小倒序排序数据库
sort -t ',' -k 2 -nr xuzhou_manyou.txt >tmp_manyou.txt
1.4 去除字段中的空白spa
cat xuzhou_manyou.txt|awk 'BEGIN{FS=",";OFS=","}{print substr($1,1,11),$2,$3}'>tmp_manyou.txt
2 在数据库中进行处理code
2.1.删除不以1开头的号码orm
delete from tmp_xuzhou_bendi where calling not like '1%'
2.2删除不是11位数的号码排序
delete from tmp_xuzhou_bendi where len(rtrim(calling))<>11