Day 2: GNU sed Other implementation of sed may also suffice, but it’s tested only on GNU sed. Thanks to @Kolsky for the idea of replacing batches of newlines with digits.