gpt4 book ai didi

bash - 在 bash 中可以使用纳秒级的 strftime 吗?

转载 作者:行者123 更新时间:2023-11-29 09:05:14 25 4
gpt4 key购买 nike

有没有办法在 bash 中使用 strftime 获得纳秒级的 Unix 时间?

我的 unix 时间线:

<command> |  awk '{ print strftime("%s"),  $0; }'

我不能使用 date +%N 因为 date 只计算一次。

有解决办法吗?

最佳答案

我找到了一个变通方法,使用 while read。日期以这种方式更新。不需要 strftime。

<command> |  while read line; do d=`date +%s%N`; echo $d $line; done

关于bash - 在 bash 中可以使用纳秒级的 strftime 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3418590/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com