The only thing I need to see in the output is which functions were called.
Input:
ibv_rc_pingpong-759367 [005] 8391981.416466: funcgraph_entry: | ib_enum_all_devs() {
ibv_rc_pingpong-759367 [005] 8391981.416472: funcgraph_entry: 29.337 us | ib_get_device_fw_str();
ibv_rc_pingpong-759367 [005] 8391981.416504: funcgraph_exit: 38.787 us | }
ibv_rc_pingpong-759367 [005] 8391981.416543: funcgraph_entry: 1.191 us | ib_enum_all_devs();
ibv_rc_pingpong-759367 [005] 8391981.416621: funcgraph_entry: 1.371 us | ib_device_get_by_index();
ibv_rc_pingpong-759367 [005] 8391981.416624: funcgraph_entry: | ib_get_client_nl_info() {
ibv_rc_pingpong-759367 [005] 8391981.416628: funcgraph_entry: 0.890 us | ib_uverbs_get_nl_info();
ibv_rc_pingpong-759367 [005] 8391981.416630: funcgraph_exit: 6.174 us | }
The output should look like this:
ib_enum_all_devs() {
ib_get_device_fw_str();
}
ib_enum_all_devs();
ib_device_get_by_index();
ib_get_client_nl_info() {
ib_uverbs_get_nl_info();
}
This is what I tried:
cat myfile.dat | awk '{print $7}'
However, this gives me garbage.
CodePudding user response:
Why don't you use the pipe character as a field separator?
cat myfile.dat | awk -F "|" '{print $2}'
... and as usual I've done [a useless use of cat][1]
:
awk -F "|" '{print $2}' file.txt
CodePudding user response:
You may use this awk
:
awk -F ' \\| ' '{print $NF}' file
ib_enum_all_devs() {
ib_get_device_fw_str();
}
ib_enum_all_devs();
ib_device_get_by_index();
ib_get_client_nl_info() {
ib_uverbs_get_nl_info();
}
CodePudding user response:
I would harness GNU AWK
for this task following let file.txt
ibv_rc_pingpong-759367 [005] 8391981.416466: funcgraph_entry: | ib_enum_all_devs() {
ibv_rc_pingpong-759367 [005] 8391981.416472: funcgraph_entry: 29.337 us | ib_get_device_fw_str();
ibv_rc_pingpong-759367 [005] 8391981.416504: funcgraph_exit: 38.787 us | }
ibv_rc_pingpong-759367 [005] 8391981.416543: funcgraph_entry: 1.191 us | ib_enum_all_devs();
ibv_rc_pingpong-759367 [005] 8391981.416621: funcgraph_entry: 1.371 us | ib_device_get_by_index();
ibv_rc_pingpong-759367 [005] 8391981.416624: funcgraph_entry: | ib_get_client_nl_info() {
ibv_rc_pingpong-759367 [005] 8391981.416628: funcgraph_entry: 0.890 us | ib_uverbs_get_nl_info();
ibv_rc_pingpong-759367 [005] 8391981.416630: funcgraph_exit: 6.174 us | }
then
awk '{print substr($0, 84)}' file.txt
gives output
ib_enum_all_devs() {
ib_get_device_fw_str();
}
ib_enum_all_devs();
ib_device_get_by_index();
ib_get_client_nl_info() {
ib_uverbs_get_nl_info();
}
Explanation: you have file with fixed-width column, I simply use substr
function to get part of whole line ($0
) starting at 84th character.
(tested in GNU Awk 5.0.1)