Lurker News
A command line trick, a random factoid, anything that’s interesting to you.

Comments (762) 128 threads

Earlier comments
znpy3 replies#
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)

geocar#
pax is POSIX:

    (: > f;echo "$((0$(pax 2>/dev/null -x ustar -wd -- f|dd 2> /dev/null bs=4 skip=34 count=3|tr -d '\0')))";rm -f f)
which might be beneficial to remember if your file server has a better clock than you do.

also, if you're actually targeting POSIX, you should make sure you've set PATH="`getconf PATH`" to guarantee you get the POSIX version of utilities.

schoen1 reply#
It's definitely not POSIX, but a good GNUish way is

  date +%s
Your portable suggestion worked in gawk, nawk, and mawk -- cool!
znpy#
> Your portable suggestion worked in gawk, nawk, and mawk -- cool!

indeed, that's the cool thing about it!

1vuio0pswjnm7#
Isn't the c99 utility POSIX-compliant. The c99 utility is an interface to a standard C compilation system.^1

1. https://web.archive.org/web/20201202084055/https://pubs.open...

   cat > epoch.c
   int printf(const char *__restrict, ...);
   unsigned int time(unsigned int *tloc);
   int main(){printf("%u\n",time((unsigned int *)0));}
   ^D
   c99 epoch.c
   ./a.out
akudha1 reply#
There is a small but growing community of people who eat only raw fruits and raw vegetables. I tried it and it was awesome (though it was expensive and I had trouble getting quality produce).

I find this community very knowledgeable, smart and down to earth. It was impressive to see a 40+ year old body builder (he is no Arnold, but has impressive physique for an amateur) doing so well on this diet.
If someone is interested, spend some time googling this topic. It is well worth your time.

jonwest1 reply#
Isn’t that what Steve Jobs did before he died?
akudha1 reply#
Yes, but he tried it too late. It is not like cancer would go away by eating fruits for a few weeks. Also eating raw diet doesn't mean one should not get modern medical treatment, especially for killer diseases like cancer. It would take years to undo decades of bad eating habits.

Eating raw is not a panacea. But it is a solid step in getting and maintaining a healthy body and mind, especially as one ages.

JudgePenitent#
IIRC he had started this diet (eating only raw carrots and strawberries) before he founded apple with woz

Load more comments