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
Date command is an external bash program that allows to set or display system date and time. It also provides several formatting options. Date command is installed in all Linux distros by default. Type date command in terminal which will display current date and time.
$# is the number of positional parameters passed to the script, shell, or shell function. This is because, while a shell function is running, the positional parameters are temporarily replaced with the arguments to the function. This lets functions accept and use their own positional parameters.
Again, $() is a command substitution which means that it “reassigns the output of a command or even multiple commands; it literally plugs the command output into another context” (Source).
bash [filename] runs the commands saved in a file. $@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With