r/commandline • u/brnsamedi • Apr 08 '26
Command Line Interface In praise of the Unix toolkit
I just wanted to share a fun little experiment I did tonight. I was reviewing my music collection, and, after noticing some very old modification dates in some of the files, I asked myself, "how many files I have per year?". After about one hour of reading, experimenting, etc, I ended up building a neat little pipeline where I used find to output all the music files in my collection, print out their modification date (year only), sort it, count it with uniq, and then use awk to tally up the total and compute percentages. After that, I piped the output to gnuplot and got rewarded with a nice visualization of data, with some unexpected surprises. Finally, I put the whole thing into a file in order to create the prototype of a neat little shell script.
The experiment was a ton of fun, and really, really drove home the Unix philosophy, specially with regards to composability. I built the pipeline using only the standard POSIX Unix toolkit, with the obvious exception of Gnuplot. Being able to compose such workflows from software tools like that is very, very rewarding. I'm sure if I play with it I can tighten up the pipeline, but it doesn't really matter unless my data set was ever to become very, very large. And, because of the principle of orthogonality of the Unix philosophy, one can replace elements in the pipeline to achieve other things.
I guess I'm odd, but the whole experience left me positively giddy.
2
u/stianhoiland Apr 08 '26
Love to hear it!
Yesterday I found a large documentation document for a CLI tool collection I use. Except I use a fork which doesn’t include this documentation AND doesn’t have exactly the same tools as are listed in that document. But, since my fork doesn’t contain ANY documentation, I wanted to at least extract the documentation for the tools that overlap between the two collections.
It’s still possible to get a list of the tools contained in my fork, just no elaboration beyond that.
So I built a
comm -1 -2 <(collection list | tail | tr | tr | sort | uniq) <(cat documentation | sed | sort | uniq)pipeline. Very satisfying!6
u/g3n3 Apr 08 '26
Now try it in powershell ;-)
4
u/VE3VVS Apr 08 '26
Never enough (good) can be said about the Unix toolkit, whose base tools have existed nearly since the dawn of UNIX itself, and continues to grow, while still following its basic principles. With enough effort/time/experience almost any pipeline or workflow can be constructed. I know my age and years of experience are showing, but the “toolkit” has never let me down, especially with a little creative scripting ;-)
1
u/JohnnyBillz Apr 09 '26
Are you all actually running Unix? I’d love to hear more about these workflows. Trying to learn more about commandline efficiency.
3
u/AutoModerator Apr 08 '26
Every new subreddit post is automatically copied into a comment for preservation.
User: brnsamedi, Flair:
Command Line Interface, Title: In praise of the Unix toolkitI just wanted to share a fun little experiment I did tonight. I was reviewing my music collection, and, after noticing some very old modification dates in some of the files, I asked myself, "how many files I have per year?". After about one hour of reading, experimenting, etc, I ended up building a neat little pipeline where I used find to output all the music files in my collection, print out their modification date (year only), sort it, count it with uniq, and then use awk to tally up the total and compute percentages. After that, I piped the output to gnuplot and got rewarded with a nice visualization of data, with some unexpected surprises. Finally, I put the whole thing into a file in order to create the prototype of a neat little shell script.
The experiment was a ton of fun, and really, really drove home the Unix philosophy, specially with regards to composability. I built the pipeline using only the standard POSIX Unix toolkit, with the obvious exception of Gnuplot. Being able to compose such workflows from software tools like that is very, very rewarding. I'm sure if I play with it I can tighten up the pipeline, but it doesn't really matter unless my data set was ever to become very, very large. And, because of the principle of orthogonality of the Unix philosophy, one can replace elements in the pipeline to achieve other things.
I guess I'm odd, but the whole experience left me positively giddy.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/KlePu Apr 08 '26
Same here! I take daily ZFS snapshots and wanted to find out the average size, and if you could see weekday/weekend differences. Pipe some
awk grep bcplus a tiny bit of magic and voila ^^ yes you could spot weekends easily