Follow

How to get the current time in seconds-since-the-epoch with `awk`:
```
awk 'BEGIN {srand(); print srand()}'
```

@th Works as documented ... I guess ...

srand([x])

Set the starting point, or seed, for generating random numbers to the value x.
[...]
If the argument x is omitted, as in ‘srand()’, then the current date and time of day are used for a seed.
[...]
The return value of srand() is the previous seed. This makes it easy to keep track of the seeds in case you need to consistently reproduce sequences of random numbers.

@th Wow, it's actually documented that way in the man; so it worked on both mawk and gawk.

@th wild, i love it! I can't think of any other platform where you can inspect the rng seed like that.

@phooky have you seen Guy Steele's "Fast splittable PRNG" for deterministic multi-threaded pseudorandomness? dl.acm.org/doi/abs/10.1145/266

@phooky the most famous is probably RSA's `Dual_EC_DRBG`, which allows the NSA to predict the value of the rng seed. blog.cryptographyengineering.c

Sign in to participate in the conversation
(void *) social site

(void*)