我有一个很长的JSON行,其中包含很多我希望从中查看的数据,而不会看到其他数据。
内容:
28.1270450678417,"app_delay_avrg":612,"app_delay_max":4348,"app_delay_min":0,"data_in_sum":88459347,"data_out_sum":5947410,"rps_avrg":19242,"rps_max":46843,"rps_min":120,"success_sum":32948,"errors_sum":12115,"timeout_errors_sum":779,"network_errors_sum":0,"started_at_date":"04/13/2016","started_at_time":"07:12 AM","share_box_info":{"id":1261233,"result_url":"http://loader.io/reports/ff4b7ca58e569af5a9650b9a2b856f39/results/6b4e3ae3f83407c91b10402b2e4231c6","endpoint_widget_url":"//share.loader.io/reports/ff4b7ca58e569af5a9650b9a2b856f39/widget/results/6b4e3ae3f83407c91b10402b2e4231c6","short_url
命令:root@user:/home/user# cat data.txt | grep app_delay_max\"\;:
结果(例外)和grepped内容在终端中标记为红色。
28.1270450678417,"app_delay_avrg":612,"***app_delay_max":4348***,"app_delay_min":0,"data_in_sum":88459347,"data_out_sum":5947410,"rps_avrg":19242,"r
我怎样才能获得此输出并删除其他内容?
app_delay_max":4348
答案 0 :(得分:5)
你可以尝试
grep -o 'app_delay_max":[0-9]*' data.txt
-o, - 仅匹配 仅打印匹配行的匹配(非空)部分,每个此类部分位于单独的输出行上。