The out file contains Grinder (an open source load testing tool) test data parsed to JSON
curl -s -X GET http://<localhost>:6373/recording/data' | python -mjson.tool > out ~$ cat out { "columns": [ "Tests", "Errors", "Mean Test Time (ms)", "Test Time Standard Deviation (ms)", "TPS", "Peak TPS" ], "status": { "description": "Collection stopped", "state": "Stopped" }, "tests": [ { "description": "Cheetah client test", "statistics": [ 0, 0, "NaN", 0.0, 0.0, 0.0 ], "test": 1 }, { "description": "Reads 95%", "statistics": [ 304000, 0, 8.7931875, 7.948696618436826, 6907.677974959667, 13594.0 ], "test": 101 }, { "description": "Writes 5%", "statistics": [ 16000, 0, 9.963375, 9.92775949594747, 363.5619986820878, 1638.0 ], "test": 102 } ], "totals": [ 320000, 0, 8.851696875, 8.063234652303947, 7271.239973641756, 14259.0 ] }
Sed command:
sed -nr "H;/$name/,/\}/{s/(\})/\1/;T;x;p};/\{/{x;s/.*\n.*//;x;H}" out | sed -e '1,/statistics/d' | sed -e '/test/,$d' | sed '$d' | sed '/^$/d' | tr "\\n" " " | sed -e 's/[\t ]//g;/^$/d'
gives below output - test statistics for the test "Reads 95%"
304000,0,8.7931875,7.948696618436826,6907.677974959667,13594.0
Next sed command:
sed -nr "H;/"Reads 95%"/,/\}/{s/(\})/\1/;T;x;p};/\{/{x;s/.*\n.*//;x;H}" out gives { "description": "Reads 95%", "statistics": [ 304000, 0, 8.7931875, 7.948696618436826, 6907.677974959667, 13594.0 ], "test": 101 },
pipe result 1 with | sed -e '1,/statistics/d' gives all lines after the line contains "statistics"
304000, 0, 8.7931875, 7.948696618436826, 6907.677974959667, 13594.0 ], "test": 101 },
pipe result 2 with | sed -e '/test/,$d' gives lines above the line consists "test"
304000, 0, 8.7931875, 7.948696618436826, 6907.677974959667, 13594.0 ],
pipe result 3 with | sed '$d' removes the last line of output 3 304000, 0, 8.7931875, 7.948696618436826, 6907.677974959667, 13594.0
pipe result 4 with | tr "\n" " " | sed -e 's/[\t ]//g;/^$/d' gives
304000,0,8.7931875,7.948696618436826,6907.677974959667,13594.0
tr "\n" " " replace CRs (or \n) with a space and sed -e 's/[\t ]//g;/^$/d' removes all spaces and tabs
Note: I'm not an expert in this subject area, thus this may not be the most efficient solution