Stop the war!

Stop the war in Ukraine! Fuck putin!

More information is at:

There is a fund to support the Ukrainian Army:, and there is a special bank account that accepts funds in multiple currencies: I donated to them. Please donate if you can!

Killer putin

Killer putin. Source:

Arrested putin

"It hasn't happened yet, but it will happen sooner or later. Beautiful photo, isn't it?" Source: twitter.

Introducing ssponge

| comments

sponge from the moreutils package is a nice tiny tool for a specific use case when you need to read data from a file, process it and write the result back to the same file. Some unix tools allow you to do in-place editing (e.g. sed -i) whereas others don’t (e.g. awk). Well, isn’t it as easy as reading and writing to the same file?

$ grep -v '^#' config > config

It doesn’t work in practice — you get an empty file. sponge helps here:

$ grep -v '^#' config | sponge config

It reads all the input data from the pipe and writes it to the output file only on stdin’s end.

I’ve been using it in a project to reformat multiple json files with jq. Not all of them needed reformatting on every run, but sponge rewrote the files anyway, which caused some unnecessary processing from a file watching process in the project.

I wrote an analogous tool in Haskell and added a feature of not updating the output file if it already has the same contents as stdin (as the feature isn’t present in the original version). It was easier for me to write from scratch than to modify the C code (in fact, it’s just one file). The sources are at and the binaries are at

The build instructions are in the README. I also replaced sponge with it: cd ~/.local/bin; ln -s {s,}sponge — it’s been working great for my use case of small json files. It should also work with big files as long as you have free RAM and swap space, but I haven’t tested that.