Recently I was given the task of running SQL queries from a shell script. This script used to run overnight and next day I
'd to check how much time each of the queries took and fill them up in an excel sheet. There were around 200 SQL queries which means around 200 timings. Now, the format of the output, the output were stored in a file, was somewhat like this:
========= Test Queries ========
std_q01 ... MATCH - (13.71 s)
std_q02 ... MATCH - (41.38 s)
std_q03 ... MATCH - (45.27 s)
.....
copying each timing was a tedious task and was boring too, so I thought of doing it in a different way with the help of grep,
awk and sed. How?
This is how I've done it:
grep std_ /path/of/output/file | awk ' { begin; print $5 } ' | sed 's/^(//'
Output:
13.71
41.38
45.27
From the above output the only task left for me to do is copy-paste to the excel sheet.
Excel sheet is smart enough to split them into separate cells. That's all.
'd to check how much time each of the queries took and fill them up in an excel sheet. There were around 200 SQL queries which means around 200 timings. Now, the format of the output, the output were stored in a file, was somewhat like this:
========= Test Queries ========
std_q01 ... MATCH - (13.71 s)
std_q02 ... MATCH - (41.38 s)
std_q03 ... MATCH - (45.27 s)
.....
copying each timing was a tedious task and was boring too, so I thought of doing it in a different way with the help of grep,
awk and sed. How?
This is how I've done it:
grep std_ /path/of/output/file | awk ' { begin; print $5 } ' | sed 's/^(//'
Output:
13.71
41.38
45.27
From the above output the only task left for me to do is copy-paste to the excel sheet.
Excel sheet is smart enough to split them into separate cells. That's all.