I recently discussed a method of what, in retrospect, was a run length encoding problem, solved using standard POSIX commands.
Simon Branch pointed out in an email that
fold can be used to handle the task of splitting the input to one character per line:
$ printf "aaaabbbcca" | fold -w1 a a a a b b b c c
That's a much simpler command. It's also slightly more efficient, as it doesn't involve compiling and executing a regular expression. Very elegant.Copyright © 2021 Jakob Kaivo <email@example.com>