'What does the '@' mean before a bash variable?
I'm working on a bash script that checks if a backup has been made in the last X days. The script must be run on linux and macos. My problem is, that when it checks if it's running on a linux or macos system, I don't understand what the '@' means before the 'bckpT' variable on linux part.
case "$OS" in
DARWIN)
lastBackup=$($DATE -u -r $bckpT +%F)
;;
LINUX)
lastBackup=$($DATE -d @$bckpT +%F)
;;
WIN)
$ECHO "No script for WIN"
;;
*)
help
;;
esac
When there isn't the '@', the output is:
/usr/bin/date: invalid date '1647907200'
Solution 1:[1]
In date command the @ sign tells the command to treat the following as seconds since epoch
In your case, it consider the param $bckpT value as seconds since epoch
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Saar Levy |
