4 ms·
Thoughtful article - thanks. Humorous aside: I recently came across a hilariously named, occasionally useful, related utility: "tac".
by gregfjohnson 3y ago
Thoughtful article - thanks. Humorous aside: I recently came across a hilariously named, occasionally useful, related utility: "tac".
- ryukoposting 3y agoIt ships with coreutils! `rev` is another one in a similar vein, though that's not coreutils.
- mprovost 3y agoI'm a bit surprised `rev` isn't in coreutils, it's ancient. Originally written because `cut` doesn't allow selecting fields from the end of a line. So to get the last field in each line, you reverse each line (right to left) with `rev`, select the first field with `cut`, and then reverse it again with `rev`.
- ryukoposting 3y agoOn my Ubuntu machines, `man rev` indicates that it came with a package called util-linux, so it seems like it might actually considered even more essential than coreutils. Funny enough, that manpage lists `tac` under its "See Also" section, so maybe these two packages are tied together at the hip. You describe a really clever use case for rev. On the surface, my intuition was that reversing, cutting, and reversing again wouldn't work if you had escape sequences, but I suppose that's a moot point with cut!