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.3k times
3
-
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
4
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"

Zombo
- 1
- 62
- 391
- 407

Stephane Chazelas
- 5,859
- 2
- 34
- 31