English 中文(简体)
• 如何在双流中用双管子接过过去的时间?
原标题:How to get the elapsed time in milliseconds in a bash script?

我尝试使用<代码>t1=$(日期+%s%N)在纳米秒中抽取时间,但我保留这一错误:

./script.sh: line 10: 1292460931N: value too great for base (error token is "1292460931N")

我在网上研究,似乎你可以使用“时间”指挥系统,但我找不到使用时间指挥的良好例子。 任何帮助都值得赞赏:

最佳回答

Okay, 这里的两件事。

首先,许多系统不能给你一个实际上准确对待纳米秒的时间。

现在,使用时间,无论是作为<代码>/usr/bin/time,还是作为(bash:helptime)的校车,都是非常容易的。 如果你想要用<代码>foo1,则

$ time foo

时间已过,再接三条楼梯线。

real 0m0.001s
user 0m0.000s
sys  0m0.000s

你们可以使用任何方式。

如果你想要获得更好、更准确的时机,就会多次执行指挥。 这既简单又简便。

time for i in 0 1 2 3 4; do foo; done

<代码>foo5倍,给你全时。 你们可能想做5个以上的麻烦,因此,你可能想要的是反之和 while。

问题回答

www.un.org/Depts/DGACM/index_french.htm 页: 1 因此,您的产出字面上是1292460931N。 我尝试了它,它工作了,但关于自由BSD,我看到你的结果。 该日指挥着一枚炮弹,看看着什么。 您是否可以重新使用<代码>燃烧箱? 其截止日期指挥也为%N,但我刚刚尝试过的版本为12924635N





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...

热门标签