What command can I use in linux to display the time in unix format i.e. no of seconds since epoch (01/01/1970)?
Asked
Active
Viewed 1.1k times
2
-
possible duplicate of [get current time in seconds since the Epoch on Linux, Bash](http://stackoverflow.com/questions/1092631/get-current-time-in-seconds-since-the-epoch-on-linux-bash) – Alex K. Jun 10 '13 at 14:21
-
1Check the man pages for stuff like this, it'll save you time - looking at `man date` will show you this note: `%s seconds since 1970-01-01 00:00:00 UTC` – Mike Jun 10 '13 at 14:21
3 Answers
3
GNU and BSDs:
date +%s
With most Awk implementations:
awk 'BEGIN{srand(); print srand()}'
Probably the most portable out of Linux:
perl -le 'print time'
With shell builtin, ksh93 or Bash 4.1 or above:
printf '%(%s)T'
With shell builtin, zsh:
zmodload zsh/datetime
echo "$EPOCHSECONDS"
![](../../users/profiles/1002260.webp)
Steven Penny
- 82,115
- 47
- 308
- 348
![](../../users/profiles/1627296.webp)
Stephane Chazelas
- 5,014
- 2
- 27
- 29