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