1. 程式人生 > >awk,grep,sed三劍客

awk,grep,sed三劍客

日誌 sed linux 命令 href print osc .net ... nec

想學好“三劍客”最基本還是 正則表達式的熟練

正則表達式全集

日誌的格式

2018/10/03 23:59:14.944 adapter.go:353: [warning] [SLOW_QUERY] cost_time:111.420169ms succ:true connection_id:0 txn_start_ts:403375431254540289 database: table_ids:[21] index_ids:[1] sql:select tab_id, is_ind, hist_id, distinct_count, version, null_count, tot_col_siz from mysql.stats_histograms where table_id = 40373
...
grep "[0-9]m[0-9]" slow-log-2018-10-06.log |awk -F":" ‘{print $6, $NF}‘ |sed ‘s/succ//g‘ > slow_sql-2018-10-08.log

grep "[4-6][0-9]\.[0-9]\{2,\}s" slow-log-2018-10-06.log

grep ":9[0-9][0-9]\." slow-log-2018-10-06.log |awk -F":" ‘{print $6, $13}‘ | grep ‘limit‘

Linux 命令——grep | 正則表達式

awk,grep,sed三劍客