3 ms·
Never heard of sponge. Isn’t it just the same as tee ?
by indigodaddy 5y ago
Never heard of sponge. Isn’t it just the same as tee ?
- halostatue 5y agoIt’s part of the moreutils collection and is better considered a buffered redirect than anything similar to `tee`.
- indigodaddy 5y agoAh yes I glanced too quickly over the surface here. It does look more like redirection. Will have to look at it more. Appreciate your helpful response vs the downvoters and the one unhelpful/snarky response.
- AshamedCaptain 5y agoThe point is not to truncate the file immediately when it is open for output, and before the input side has had time to slurp it.
- binwiederhier 5y agoI urge you to actually read the link before commenting. sponge is the front and center example of the link you are commenting on.
- indigodaddy 5y agoThe downvoting here is the equivalent of getting shamed for “asking a stupid question at work.” Yes I should have done a bit more homework but shaming for asking a clarifying question is unreasonable. Those of you who have the downvote trigger-finger can and should do better.
- HellsMaddy 5y agoI agree with you, the downvotes are unnecessary, it was actually a good question. tee actually does sorta work for this sometimes, but it’s not guaranteed to wait until EOF. For example I tested with a 10 line file where I ran `sort -u file.txt | tee file.txt` and it worked fine. But I then tried a large json file `jq . large.json | tee large.json` and the file was truncated before jq finished reading it.
- dang 5y agoI wouldn't overinterpret the downvotes - it's impossible to know what people were thinking, and the mind tends to arrive at the most irritating, annoying, or hurtful explanation. The same principle works the other way too - when a comment doesn't contain much information, readers tend to interpret it according to whatever they personally find the most irritating, annoying, or hurtful, and then react to that. Our minds are not our best friends this way. The (partial) solution to this is to include enough disambiguating information in your comment. For example if your comment had contained enough information to make clear that your question was genuinely curious rather than snarkily dismissive, I doubt it would have gotten downvoted. It's hard to do that because generally our intention is so clear and transparent to ourselves that it doesn't occur to us to include it in the message. Unfortunately for all of us on the internet, however, intent doesn't communicate itself.
- indigodaddy 5y agoThis is very helpful feedback and does make a lot of sense. Appreciate it.