通过shell处理多行数据
### 源文件 cat > tmpb <<'EOF' dbname:db_a,start_time:17:01:13 query_end_time:17:01:13,query_total_time:0,data_record_num is [341],data_size is 337K dbname:db_a,end_time:17:01:13 total time:0 ============================== dbname:db_b,start_time:17:01:13 query_end_time:17:01:17,query_total_time:4,data_record_num is [20393],data_size is 20M dbname:db_b,end_time:17:01:24 total time:11 ============================== dbname:db_c,start_time:17:01:24 query_end_time:17:01:24,query_total_time:0,data_record_num is [615],data_size is 497K dbname:db_c,end_time:17:01:24 total time:0 ============================== dbname:db_d,start_time:17:01:24 query_end_time:17:01:25,query_total_time:1,data_record_num is [8],data_size is 6.4K dbname:db_d,end_time:17:01:25 total time:1 ============================== EOF ### 清洗数据 cat tmpb|while read line do if [ "${line}" == '==============================' ] then echo "" else echo -n "${line}|" fi done \ |awk -F'[|:, ]' '{print $2"|"$4":"$5":"$6"|"$8":"$9":"$10"|"$12"|"$15"|"$18"|"$27}'|sed 's#\[##g'|sed 's#]##g'|sort -t '|' -nk5