afaik the only way to get epoch with only posix-compliant tools is to use awk: $ awk 'BEGIN {srand(); t = srand() ; print t}' 1651247949 explaination: 1. srand if not provided with a seed will use the current unix epoch as seed 2. srand will return its previous seed in a new initialization (and we assign it to t) 3. we print t I learned this via a "Systems we love" talk ( https://www.youtube.com/watch?v=IfhMUed9RSE )
It's definitely not POSIX, but a good GNUish way is date +%s Your portable suggestion worked in gawk, nawk, and mawk -- cool!
indeed, that's the cool thing about it!