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)}'
精彩评论