In other words, I wanted to select columns from the output and have them printed neatly and aligned. Don’t ask me why, I guess it’s just some form of OCD.
Attention to detail is not OCD. You prefer this type of output because it communicates the results cleanly and so lightens the computational load on your reader, even when that is yourself. Sloppy output increases the work needed to comprehend, and also unnecessarily detracts from the reader’s confidence in your work. Not saying you should paper over bad results with fancy formatting, just that bad formatting is like asking someone to look through a dirty window.
(Author here) You’re right, of course. The link to “some form of OCD” wasn’t meant as any sort of negative, but I did have a slight wondering in the back of my mind about why I’d not seen this requirement (or practice) often, at least in the context of shell output, in the brief searches I did before embarking on the script.
That’s lovely. In fact, I’d started looking at column at the outset of this little adventure, then got completely distracted by the lure of the AWK language, and promptly forgot about everything else. I’ve added an update to the post. Thanks!
This is a well explained post, way to go. I remember the last post I read on your site being so well thought out as well. I love me some awk. In Python there is PrettyTable which I use often, but for awk and shell in general this is nice.
BTW, since publishing this post, I’ve made a couple of updates, incorporating gioele’s helpful comment and also some great input from the user oh5nxo on /r/commandline. Thanks both!
In other words, I wanted to select columns from the output and have them printed neatly and aligned. Don’t ask me why, I guess it’s just some form of OCD.
Attention to detail is not OCD. You prefer this type of output because it communicates the results cleanly and so lightens the computational load on your reader, even when that is yourself. Sloppy output increases the work needed to comprehend, and also unnecessarily detracts from the reader’s confidence in your work. Not saying you should paper over bad results with fancy formatting, just that bad formatting is like asking someone to look through a dirty window.
(Author here) You’re right, of course. The link to “some form of OCD” wasn’t meant as any sort of negative, but I did have a slight wondering in the back of my mind about why I’d not seen this requirement (or practice) often, at least in the context of shell output, in the brief searches I did before embarking on the script.
It is always nice to see new AWK scripts pop up!
Here is an alternative for those who want to stick to classic Unix commands
That’s lovely. In fact, I’d started looking at
column
at the outset of this little adventure, then got completely distracted by the lure of the AWK language, and promptly forgot about everything else. I’ve added an update to the post. Thanks!This is a well explained post, way to go. I remember the last post I read on your site being so well thought out as well. I love me some awk. In Python there is PrettyTable which I use often, but for awk and shell in general this is nice.
Thanks, I appreciate that. I find that explaining things (or trying to) helps me understand, too.
BTW, since publishing this post, I’ve made a couple of updates, incorporating gioele’s helpful comment and also some great input from the user oh5nxo on /r/commandline. Thanks both!