开发者

gawk : extracting data from special symbols

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜