16

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
5
  • Questions that are incomplete without content behind a link need to have enough of a a quotation from behind that link to be understood and answered even if the content behind that link changes or dies -- just the same as how we don't accept answers relying on links unless they directly quote enough to be useful and understood even if the link dies. Feb 25, 2015 at 14:42
  • Thank you for the addition, but i'm not quite happy with the change ot the topic, because it doesn't reflect my misunderstanding anymore of the @-sign being a bash element. The question doesn't really make sense anymore with this topic. Feb 26, 2015 at 12:50
  • Is this better? I'm trying to arrive at something accurately reflects the actual problem in such a way that someone with the same problem would find it, but that doesn't imply behaviour/semantics that don't actually exist to folks just looking at questions by title, and that doesn't draw folks curious about obscure shell syntax and features in just to be disappointed. Feb 26, 2015 at 15:27
  • (Incidentally, there actually is other bash syntax that uses the @ symbol, in extglobs; someone just seeing the original title could expect the question to be about them). Feb 26, 2015 at 15:29
  • Thanks, i'm ok with that. Feb 27, 2015 at 16:18

2 Answers 2

11

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.

2

Came here looking for the same thing as OP. Haven't found an answer yet but just in case someone else finds it useful, the @ symbol can also be used with curl to send a raw bytestream via a file:

curl http://my.domain.com --data-binary @file.dat

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.