rust string str?你想在Rust学习吗?Go考虑简单字符串插值特性
大家好,我是煎鱼。在日常开发 Go 工程中,我们经常会用 fmt.Printf 或 fmt.Sprintf 去写类似的拼装字符串的业务。如下代码:fmt.Printf("Hello Gopher %s
顺晟科技
2022-10-19 10:43:28
247
比如这个文件,我想找到#Query_time对应的值从大到小对应的sql语句,从而帮助优先处理查询时间最长的sql,在linux中应该怎么去做呢?
select * from users5;
#Query_time: 5
select * from users3;
#Query_time: 3
select * from users4;
#Query_time: 4
cat file | awk 'NR%2{line=$0;next} {print $0" "line}' | sort -k 2 -nr | cut -d ' ' -f3-
awk 'NR%2{url=$0;next} {print $0" "url}'
:首先合并前两行,偶数行在前,结果就是 #Query_time: 3 select * from users3;
sort -k 2 -nr
:根据第二行数字倒序排序cut -d ' ' -f3-
:移除非 sql 内容结果
select * from users5;
select * from users4;
select * from users3;
大概的思路就是把两行合并成一行,然后用sort命令倒序排序:
awk '{ getline nextline; print nextline, $0 }' api.log | sort -k 2 -nr
希望能帮助到你。
26
2023-02
30
2022-11
30
2022-11
29
2022-11
29
2022-11
29
2022-11