Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从 strace -T 获取总时间,报告为:
pid 命令 [时间]
(对于每个系统调用)
现在我想总结 [time] 。我正在使用 gawk,并且我知道可以使用 $NF 访问最后一个字段。但是, $NF 报告 [time] (带括号)而不仅仅是时间,我显然无法总结,所以我要问的是如何获得 time 而不是 [time] ?
谢谢
您可以通过更改字段分隔符来获取“[时间]”中的“时间”:
awk 'BEGIN {FS="[\\[\\]]"}; {print $(NF-1)}'