Date
以納秒精度進入 moreutils 的 ts?
在這個系統上:
$ cat /etc/issue Ubuntu 14.04.4 LTS \n \l $ uname -a Linux mypc 3.19.0-56-generic #62~14.04.1-Ubuntu SMP Fri Mar 11 11:03:33 UTC 2016 i686 i686 i686 GNU/Linux $ apt-show-versions -r moreutils liblist-moreutils-perl:i386/trusty 0.33-1build3 uptodate moreutils:i386/trusty 0.50 uptodate
…我可以使用
date
納秒精度,沒問題:$ date +'%Y%m%d%H%M%S' 20160327133441 $ date +'%Y%m%d%H%M%S%N' 20160327133446582969969
…但是,如果我使用與
moreutils
‘相同的格式字元串ts
,則納秒精度會失敗:$ ping google.com | ts '%Y%m%d%H%M%S%N' 20160327133829%N PING google.com (216.58.209.110) 56(84) bytes of data. 20160327133829%N 64 bytes from arn06s07-in-f14.1e100.net (216.58.209.110): icmp_seq=1 ttl=54 time=32.0 ms 20160327133830%N 64 bytes from arn06s07-in-f14.1e100.net (216.58.209.110): icmp_seq=2 ttl=54 time=31.6 ms ^C
ts
在將時間戳附加到標準輸入時,有什麼方法可以顯示納秒(或微)秒精度?
從 moreutils 0.31
%.S
說明符可用,使用它代替 %S :ping google.com | ts '%Y%m%d-%H:%M:%.S' 20160327-15:01:11.361885 PING google.com (216.58.209.206) 56(84) bytes of data. 20160327-15:01:11.362056 64 bytes from bud02s22-in-f206.1e100.net (216.58.209.206): icmp_seq=1 ttl=57 time=26.3 ms 20160327-15:01:12.314243 64 bytes from bud02s22-in-f206.1e100.net (216.58.209.206): icmp_seq=2 ttl=57 time=26.2 ms 20160327-15:01:13.315651 64 bytes from bud02s22-in-f206.1e100.net (216.58.209.206): icmp_seq=3 ttl=57 time=26.3 ms