简体   繁体   中英

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

Searching the internet I found explanations only for '$@', 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: https://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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM