The rs Command

Dr Drang over at And now it’s all this has an interesting post on the Unix rs command and his use case for it. The “rs” stands for “reshape”. The idea is that given some data arranged in rows and columns, rs will change the number of rows—and therefore columns—resulting in a change of “shape” of the data. The command is a bit obscure. I’ve been using Unix since 1990 and don’t remember ever coming across it much less using it.

Still, as Dr. Drang shows, it can be really useful for reformatting data to better fit the space it lives in. Dr. Drang’s use case is to insert a long list of numerical data into an email. The list was long so he didn’t want to just paste it into the email because it would have made the email too long. Instead, he used rs to insert it as 14 rows of 6 columns, which made it fit nicely.

The command is actually quite flexible and has many options. Dr. Drang demonstrates a couple of them that he used to make the data look better. Read the post for the details.

It’s interesting that this command is still around. Oddly, it’s a macOS builtin, resulting, no doubt, from macOS’s BSD heritage. I can’t imagine it gets used all that much but when you need to change the shape of some data, it’s just the thing.

This entry was posted in General and tagged , . Bookmark the permalink.