Live data from Hacker News

Show HN: now.sh

github.com

41–45 of 45 posts

Re: Show HN: now.sh

#41
post #39
post #38

Earlier quoted context omitted.

Just to be a smartarse ;): cat output.txt some input EOF

Maybe I'm missing it, but this doesn't seem applicable to what my sponge program (and joeyh's) are intended to do: to modify a file "in-place". joeyh's example: sed "s/root/toor/" /etc/passwd | grep -v joey | sponge /etc/passwd My example: sort

Maybe in my quest to be a smartarse, I'm the one missing it... but why can't you just use > in both those cases?

EDIT -- after tinkering around with the console, I see. I'm wiping the file out by writing to it (>) before it's finished reading (<). Neat, TIL!

Re: Show HN: now.sh

#42
post #39
post #38

Earlier quoted context omitted.

Just to be a smartarse ;): cat output.txt some input EOF

Maybe I'm missing it, but this doesn't seem applicable to what my sponge program (and joeyh's) are intended to do: to modify a file "in-place". joeyh's example: sed "s/root/toor/" /etc/passwd | grep -v joey | sponge /etc/passwd My example: sort

Couldn't you just use 'tee'?

whatever /dev/null

Re: Show HN: now.sh

#43
post #30
post #9

Another alternative is 'ts' which is part of joey hess's awesome collection of unix tools, moreutils.[1] I did not find out about ts until too late so I am still in the habit of using tai64n from djb's daemontools, which adds a tai64 timestamp to every file[2] and then tai64nlocal[3] in order to convert the timestamps to something useful to humans. If you don't know about moreutils check out the collection. I don't k…

> sponge: soak up standard input and write to a file Whoa! No kidding? I wrote a program years ago, probably around 2005, also called sponge, that does exactly this[1]. I'm not sure how to feel about this. Obviously the idea was a good one, but it's equally obvious I suck at getting the word out about my creations. [1] https://github.com/graue/graue-utils/blob/master/sponge.c

sponge () { tac|tac; }

EDIT: this doesn't work for the "sed s/foo/bar/ file|sponge file" case, but it does for certain other usages where you basically want to wait until EOF before outputting

Re: Show HN: now.sh

#44
post #39

Earlier quoted context omitted.

Maybe I'm missing it, but this doesn't seem applicable to what my sponge program (and joeyh's) are intended to do: to modify a file "in-place". joeyh's example: sed "s/root/toor/" /etc/passwd | grep -v joey | sponge /etc/passwd My example: sort

Couldn't you just use 'tee'? whatever /dev/null

Oh, cool. That does seem to work, when using GNU coreutils. So either:

1. I never thought to try that. How silly of me. OR

2. Perhaps tee behaves differently on OpenBSD (which I was using at the time).

Re: Show HN: now.sh

#45
How about a script: a wrapper to run any other script or process, that logs both STDOUT and STDERR in one file, but prepends a short string of your choice for lines that are from STDERR.
Post reply on HN