以下 3 行示例是通过 提取的:
grep "Time to convert event = "[1-9] output.log
但是我需要能够从低到高排序,之后的数字Time to convert event = x.xxxxxx
如何才能做到这一点 ?
2019-10-31 07:18:17.770 INFO [WORKER_Thread-4] [blahblah:212] [userID:] [eventID:] [objectID:] [] Time to convert event = 5.516262
2019-10-31 07:18:17.770 INFO [WORKER_Thread-4] [blahblah:212] [userID:] [eventID:] [objectID:] [] Time to convert event = 19.516262
2019-10-31 07:18:17.770 INFO [WORKER_Thread-4] [blahblah:212] [userID:] [eventID:] [objectID:] [] Time to convert event = 0.316262
答案1
sort
允许 a) 指定字段分隔符 ( -t
),b) 按字段排序-k
,以及 c) 按-n
数字排序。
grep "Time to convert event = [1-9]" output.log | sort -n -t= -k2
当我们利用只有一个=
并且就在数字之前时,您需要。