当前位置: 动力学知识库 > 问答 > 编程问答 >

What does the at-sign @ mean in the bash command: date --date @...?

问题描述:

Searching the internet I found explanations only for '[email protected]', meaning 'expand to positional parameters'. But I couldn't find anything about the @ sign by itself.

I stumbled over it in the third snipped of the accepted answer to this question:

http://superuser.com/questions/611538/is-there-a-way-to-display-a-countdown-or-stopwatch-timer-in-a-terminal

Specifically:

date -u --date @$((`date +%s` - $date1)) +%H:%M:%S

网友答案:

In the context you show, the @ is in the beginning of the --date argument to the date command:

date -u --date @$((`date +%s` - $date1)) +%H:%M:%S

In that case it means that the argument should be treated as the number of seconds since epoch, see an example in man date:

Convert seconds since the epoch (1970-01-01 UTC) to a date

$ date --date='@2147483647'

or:

$ date -u -d @0
Thu Jan  1 00:00:00 UTC 1970

This meaning of @ is defined by the date utility alone and not by bash.

分享给朋友:
您可能感兴趣的文章:
随机阅读: