开发者

gawk : extracting data from special symbols

开发者 https://www.devze.com 2023-03-18 03:43 出处:网络
I am trying to get the total time from开发者_开发知识库 strace -T, which is reported as : pid command [time]

I am trying to get the total time from开发者_开发知识库 strace -T, which is reported as :

pid command [time]

(for each system call)

Now I want to sum the [time] . I am using gawk, and I know that the last field can be accessed with $NF . However, $NF reports [time] (with brackets) instead of just time, which I obviously can't sum up, so I what I ask is how do I get time instead of [time] ?

Thanks


You can get to "time" in "[time]" by changing the field separator:

awk 'BEGIN {FS="[\\[\\]]"}; {print $(NF-1)}'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号