If Only The Kids Knew About Pipes

Being a parent is hard work. You need to prepare your child to operate in the world. Reading, writing, arithmetic, and how to make good choices are just the beginning. They also ought to know regular expressions and Unix pipes. [Jackdoe] can help with that last one, thanks to their Unix pipe card game.

As an example, the task “print the most common line from a file” would require the answer:

cat 03.txt | sort | uniq -c | sort -n | tail -1

You can vary the rules to declare whoever has the smallest pipe or the largest pipe that accomplishes the task as the winner. We’d add a house rule that whoever has the fastest pipe ought to get something. We don’t, however, think this card game will make the Vegas tables, unfortunately.

You can print your own card deck and even the box. Or you can buy a nice set, if you don’t want to spend the time. You should probably know about cat, grep, tail, head, wc, sort, and uniq along with their options.

If you want some other esoteric kids’ learning activities, they also have “Programming Time” which teaches algorithms and Python, and “4917” to teach the basics of machine code.

If you want help with the other key skill — regular expressions — check out regexp golf or crosswords.

50 thoughts on “If Only The Kids Knew About Pipes

  1. No thanks, this is just rote memorization, and is not a replacement for experience in using a Unix-based machine. We invented man pages and code comments so that we wouldn’t have to memorize what all of our shell functions and scripts execute. There is just no way and no point to memorizing everything, especially if you change jobs or career focus.

    Personally I didn’t learn squat about computers by reading books or playing with flash cards. I learned everything I needed to perform well in a professional IT world by pirating video games and customizing hardware for competition. As many professionals can attest, computers in a data center are not much different from computers at home, and so everything else specific to the business world could be learned on the job. The books just provide a reference for the things I don’t have direct experience with, or when I need to build something to spec. But most of the time it’s just faster to find all of the answers with a search engine.

    The best way to get your kids into computers is to give them a broken one or a disassembled one, and have them fix or build it. And by the end of it they’ll have a usable tool and worthwhile experience, as opposed to snips of paper.

    1. Yeah, all that time spent learning addition and subtraction was a waste too when you can just punch it into a calculator app on your phone. Please don’t ever apply for a job anywhere I’m working.

      1. If you are so much into memorization and against actual experience, please don’t apply in MY field. We’ve got way too many pseudo-HW engineers who think that since they used Arduino once, they can make electronics.
        The difference is that while you can do maths for practical uses in your head, you don’t run POSIX text parsing tools in your head. So remembering every tiny bit about them is nonsense since you still need a computer to use them…

        1. You are pretty useless as a modern c programmer if you haven’t memorized the posix threads manual. What are the semantics for semaphores and mutexes? Is your code thread safe? Will it deadlock? You need this stuff at your fingertips. Modern code is chock full of multi threaded algorithms, otherwise all those cores are wasted. If you have to reach for the manual for every line of code then you are out of your depth.

          1. IF (that’s “IF”) anyone’s suggesting that there isn’t underlying math in “computer science” I suggest you dip into Knuth’s books and get back to us. Remember there were no “computer scientists” when computers were invented. And it wouldn’t kill you to learn how a bubble sort is done; you’ll still have brainspace left for your shopping list.

        2. Besides, the text or data we’re commonly dealing with is not in a nice plain text file anyways, but on a web page or PDF document, some other special format, or even a scanned picture, and it’s basically impossible to use these tools on the data anyhow without first going through a whole heap of trouble to reformat it in some way to fit these “simple” UNIX command line tools.

          But of course they’re handy if all you ever do on your computer is tweaking your UNIX-derivative operating system configuration files.

          1. I’ve created more than a few scripts dealing with websites its really not a problem for these tools you just have to parse the data first – so generally a wget followed by a regular expression to make the data a nice plain text file containing only what you need..
            It does take some time to construct, but with how horrible and inconvenient many websites are to actually do something – for instance download everything you purchased in the last month/year whatever being 20 mouse move and click per file it is rapidly worth it.

      2. Pseudo-elitism is a flimsy shield. A uni professor once told me solving logs on wetware is wasted intelligence. Besides I highly doubt you can run MATLAB in your brain. “Please don’t apply where I work” yourself.

        1. There is some value in memorizing more complex mathematics. It makes you remember the simpler math. Set the bar slightly higher than what you actually need, and the important bit becomes easy.

          I’ve seen students today who struggle to solve a quadratic equation on paper, because they’ve relied on symbolic solver calculators their entire life. Trying to teach any technical subject becomes difficult when you’re bogged down doing remedial algebra just to explain the mechanics of using some solution. For the students as well, it’s an enormous waste of time and a source of stress that they have to essentially re-learn stuff every time because they haven’t gone through the trouble of memorizing the basics.

    2. Unless you are getting them to install linux or a bsd on their repaired hardware, they will likely never even get the opportunity to even suspect what is possible by combining tools using STDIO, as they simply consume shiny GUI products sold to them as SaaS on their hardware, which they are soon required to upgrade due to forced obsolescence.

      K&R’s C book has a sentence that has influenced me greatly, explaining just how much useful work can be done reading or writing just a char at a time using STDIO.

    3. The computers in our data center are unusable as desktop machines, no desktop software is installed. They are also unusable for software development or debugging, no compilers or debuggers or editors are installed. They also have no access to the internet. They have upwards of 100 cores, terabytes of ECC RAM and petabytes of disk. These machines are utterly unlike any desktop machine.

      Software development requires advanced knowledge of mathematics, you can’t code and debug an algorithm that you don’t understand. Even plain old floating point arithmetic can present an enormous challenge to the developer, doing the right calculations in the right order to preserve precision.

      Which sort algorithm do you use? How do you decide? What if you don’t have the data sets to test, you are planning for 5he future? Answering this question correctly can be a project worthy of a masters thesis.

      Software development and advanced mathematics go hand in hand.

      The best software developers are taught at the blackboard with concepts and theory, you won’t learn about queues or semaphores or linked lists or closures or promises by messing with a broken computer.

        1. What do you mean by that? “Most software” would include machine vision libraries and graphics libraries and video codec libraries and compilers and database storage algorithms and every single line of all of it has been carefully optimized, proper algorithms chosen, etc. You underestimate how much work has gone into the software you get for free.

          1. I would argue that “most software” would not include those. Most is defined as “greatest in quantity, extent, or degree”. Those kinds of software are a small minority of the software written these days. Yes, they are vitally important to modern computing, but are not being coded on a massive scale as something like web applications are.

          2. You think large scale web apps are not carefully coded for efficiency? The majority of software today is enterprise business software and it is most certainly tweaked and optimized by advanced experts.

            The entirety of all the user code in Ubuntu and all the other Linux distributions, is just a tiny bit of stuff compared to all the business applications out there. Frankly that code is mostly buggy junk and it’s not installed for enterprise use.

            You can’t support a million users if you are just phoning in the software development, you have to really solve the scaling issues. Even if you are just taking orders for pizza, these are hard problems that need real expertise.

          3. > but are not being coded on a massive scale as something like web applications are.

            A web application is a 50 kilobyte javascript file running on top of a 500 megabyte web browser application running a java virtual machine, that is running on top of a 5 gigabyte operating system. Counting lines of code, the actual application is a vanishingly small part of the whole.

          4. Web apps have extensive back end work required for scaling, the app that runs fine on your desktop will fall over immediately when presented to a million users. You will need a lot of expertise to keep it running: load balancing, database concurrency, etc. All hard problems.

      1. Honestly, it depends on what kind of software you are developing. For most software, you can get away with nothing more advanced than algebra. Yes, if you are coding something that required advanced mathematics to do like a physics engine, then you will need to understand that level of math, but most everyday software doesn’t need that.

    4. Before you can find something in the man pages, or figure out how to use it you have to know something maybe is possible via such methods so you might just look in the right place… Its not like you can find out pipes, or man pages, or ways to search for the right man page even exist by accident. Even if you know it exists it can be hard enough to find the right commands man page if you don’t know exactly what its called, or even what term computer science types in the 80’s (probably) would use to describe the operation…

      A game like this gets you thinking the way the shell works, so you can logically create your operation, and played against others you are bound to find n ways of doing it some of which are better than the one you came up with – maybe smaller, maybe easier to expand to different dataset, maybe processes faster (etc). Which is about as far from rote memorization as you can get anyway!

      1. I have found shell scripts to be too cumbersome for many system admin and building tasks, I started writing my scripts in node.js and I find myself getting them done a lot faster. There is no trouble getting them to run on windows or AIX. Node.js has better support for regexps than the shell, and it’s so much easier to parallelize tasks. The async programming style is strange at first but you grow to appreciate it as you use it.

        You already know JavaScript, right? In this day and age the web browser is the lingua franca. Most of our computer interactions are with web apps, they make the world go round. You are computer illiterate if you can’t make a JavaScript web app, it is the modern version of the hello world program in your c manual.

        1. Then by your measure I’m computer illerate (probably) as I have never wanted anything to do with JS… I probably could use it reasonably smoothly, I can certainly read code in it (at least that isn’t deliberately obfuscated) but it is one of those just different enough to catch you out situations I expect, so it wouldn’t be my goto choice.

          If JS does what you need, and can be used for the tasks you have at hand that is good for you. But for me if you are going to end up playing with systems without knowing their state, or what permissions you will have working in the more common to the point of being ubiquitous CLI tools is worth knowing. There is rarely any single one right answer, though sometimes very wrong solutions – Red Shirt likes his angle grinder as the solution to all things, Geoff the saner likes Ansible for everything it would seem, I leave you to figure out which one is fine…

      2. And you’ve just described the weakness of CLI: no discoverability. Nothing is in plain sight, and there are no hints and breadcrumbs to follow.

        You just have to know stuff, and hope that you don’t forget it because you’ll never find it again if you don’t remember what you’re missing and what is possible. If you only rarely need these tools, it becomes an exercise in futility to go back to the basics and read all the manuals all over again to remind yourself that aha, you can pipe X to Y to do Z…. which would be a single menu item and a dialog in some GUI based program.

        1. Can’t entirely agree, as the knowing its possible means a quick internet search likely gives you the exact right command you need, quite likely the correct options as well and because you did know how it worked once you should know if the results are sane and understand quickly how to tweak to get what you need done.

          Also the GUI has much the same problem still, which of the millions submenu locations is the tool that does what you want, is it even visible without first changing some config details to enable such stuff etc. Then the ever fun one dealing with Windoze too infrequently to keep up is where have they gone and hidden this bit now, when every update seems to move something to somewhere else…

          Also they usually are breadcumbs to follow in both cases, but if you have never been taught how to look for them the odds of finding them is rather low – In the same way if you don’t read Spanish you can’t properly understand the Spanish language problem infront of you and if you don’t know Spanish(or its derivatives exist) you won’t know where to start. Its not that you can’t solve it, just you have to know enough to actually look for the translation tool of choice to rephrase it in a way you do understand, and likely then rephrase your output to match the expected result.

          1. “quick internet search” usually yields incomplete or wrong answers. Don’t pretend that hard problems are easy. Finding the right algorithm is not something that you can just do with a Google search.

            Developers say “oh this is hard, I will use a shortcut I found on the web” and it becomes a world of pain for the testers and end users.

          2. The problem is asking the right question, by knowing what you should be doing, which you don’t know if you can’t remember or you’ve never done it in the first place. Otherwise your internet search results just return a bunch of gibberish and people pointing you in wrong directions, or trying to scam you for money.

          3. >which of the millions submenu locations is the tool that does what you want

            There are not a million submenus, and they’re usually categorized, grouped and named to help you discover the right option.

            >every update seems to move something to somewhere else

            That’s a different issue, yet, it is still discoverable while knowing which man page you should read next is not.The GUI at least frames your options to the immediate task, so even if you are just picking stuff at random, the number of options and paths to search is limited by context.

          4. And then there’s the lack of universal syntax. With a GUI you just poke things with a cursor or a finger to make it happen. With CLI each command carries its own flags and arguments and special grammar that you also have to learn to make it work.

            So even if you do remember that there’s command X that does something, HOW to make it do that still has to be discovered again and again as it falls out of memory.

          5. Depends on what you are doing Dude, and on what program – some of them really are nested menu galore with lots of options not even on the menu by default at all… As not everything is really suited to a GUI, and GUI that have been evolving for 40 years tend to either very paired down slick interfaces with some severe limitations on functionality or a massive sprawl of stuff as new stuff keeps turning up and getting tacked on…

            @X and @Dude
            All I am saying is that IFF you know something about what you are searching for it is a quick a search – which is where learning stuff like this is useful as you then have some memory of the right language to use and related and places to look to get the result. That is a vastly different thing to trying to find new to you stuff without that background knowledge to guide your search, which I agree can be a real minefield.

            >And then there’s the lack of universal syntax.
            Yes and no, syntax for most CLI tools is very very predictable, to the point of being pretty much universal. A quick look at the right man page usually gives you ‘The Word’ or abbreviation for the command and its details to home in on what you want more precisely…

            > HOW to make it do that still has to be discovered again and again as it falls out of memory.
            True of GUI and CLI tools, the difference there is for a skilled user familiar with using CLI stuff the CLI tool is usually going to be 5 mins of reading the manual, to maybe an hour for a complex task string (of the sort GUI are usually hopeless at). Where the GUI can end up being so wonderfully obtuse you could spend hours looking for the right spot (NB I said CAN, not always) and there usually isn’t much in the way of documentation to guide you to the weird logic of the UI design team that happened to stuff the feature you want in some illogical seeming corner (quite possibly because they don’t actually know what it does to put it in a logical space). There is no doubt a GUI is very good at many tasks, and can for the more default tasks be very easy to just pick up and run with – so please don’t think I have anything against GUI, they just are not the right tool, or wrapper for the tools, to be the most suitable for every task.

          6. >some of them really are nested menu galore with lots of options not even on the menu by default at all…

            That doesn’t have to be the case though – it mostly applies for programs made by people who fetishise the keyboard and throw in a GUI menu as an afterthought.

            GIMP for example: I like the fact that I have to read a manual to know how to draw a straight line in a drawing program, because nowhere does it say that you have to press shift while using a freehand brush tool. That’s GUI done wrong – because the underlying assumption and attitude still is that the GUI is not useful or necessary, and the user is just supposed to memorize a bunch of keyboard shortcuts instead.

          7. >>some of them really are nested menu galore with lots of options not even on the menu by default at all…

            >That doesn’t have to be the case though – it mostly applies for programs made by people who fetishise the keyboard and throw in a GUI menu as an afterthought.

            Really not the case, there are many many things for which a GUI just can’t throw everything you may want in cleanly, and even the example you gave of Gimp I’d argue is one of them, its a program with far far too much scope that needs to be slick to use not baby’s first painting program easy so reading a manaul/ watching a tutorial is entirely to be expected. As if every tool told you the full details of what it can do and every keyboard modifier to shift behavior you’d end up with hovertext explosions and the video game loading screen ‘helpful hints’ plastered everywhere to the point you can’t actually see what you are trying to work on! Even without text labels and lots of hover text huge portions of your monitor are eaten by the buttons you do need…

        2. OK, I am a dinosaur. I learned Unix in 1976 when there were no GUIs except PLATO. I had to read all of the Unix man pages from beginning to end 3 times to resolve all of the cross references. Without VI, (now VIM), I had to be a REGEX wizard to use “ed” to edit files. The man pages were better then, with examples, but the documentation was complete and comprehensible in about 1 week. The quality of man pages has declined, but there are still good CLI courses if you take that route. The reality is we all use a combination of CLI and GUI, but many folks forget you can’t scale a GUI very well. Intel marketing children once tried to tell me you could manage the power settings in a data center with a GUI that could manage 100 servers per instance. They failed to understand the scale problem when I tried to ask them how my financial customer with 40,000 machines could have the time to look at GUI screens for all of the machines that ran a Monte Carlo simulation of the opening bell market moves each night.

    1. I much prefered learning Z80 assembly after doing my homework than going out playing football with schoolmates :)
      This was in the early 80’s on an Amstrad CPC464 computer in the french countryside.
      Some 40 years later I’m still enjoying writing software and learning new programming langages.

  2. Hackaday or Crapaday? I look at Hackaday to see what is happening in the DIY world. It seems many people read Hackaday to critique other folks efforts. It is sad that many of the comments are simply trying to crap on other peoples work. If you have a better idea produce it and show it to us don’t just tell us how you did it years ago but never showed it to anyone or your way of doing it is superior without showing us the product and your work. Years ago I aced physics, chemistry and quantum mechanics. Never mind that I did not show up for exams and submit my term papers. In my mind I was a winner. So much winning that I got tired of winning.

  3. Current industry trends are clear: virtually all new paid software development is cloud based. There are no new customers for on-prem software, only maintenance of existing code. Everyone is thinking big and spending on big.

    The desktop is vanishing, the only app that matters is the browser. Distributing and updating end user software on desktops is expensive and error prone and nobody wants to do it any more. Follow the money.

    We have a whole planet of big issues to solve for everyone, we need big apps that can handle it. If you want to get a job in this business today you need to be working with large scale systems that can support a whole planet of users. You can think what you want but the industry will do what it wants. Cynicism will get you nowhere, how many users are you supporting?

    1. I don’t think the desktop is vanishing at all and as there are still far far too many folks that don’t have great internet it can’t either… But there is also no point in the cloud very often.

      For instance your CAM package being cloud based is stupid – it is probably out there with the machine tools it needs custom definition of to actually program correctly – useful so you can adjust the CAM to suit the tooling available and results you are getting directly. The last thing you want then is for a network outage to shut you down entirely, quite possibly causing a ruined part and lost day(s) of work if its cloud based, where run locally you can just keep on working as long as you have power. Not to mention being run in the workshop that quite possibly doesn’t even have a network connection, as there really isn’t a need to pay for that service or the bandwidth required in a location where ready access to the internet is likely to mean staff members missing limbs when one of them gets distracted…

      Same thing with digital artists, audio and video production and mastering, even for CGI stuff – you might leverage the cloud for heavy compute parts but you most definitely do not want to only be able to function with a fast internet connection.

      What Cloud does is allow your desktop to perhaps be a leaner less powerful machine, as you can offload the compute heavy and storage heavy stuff to cloud at some point in your workflow. But it doesn’t replace the need for the real desktop experience at the edge and I really don’t see how it can any time soon – something like Starlink might bring the bandwidth up enough everywhere to make it plausible, but the power cost of all that network activity (made worse by being a pretty high powered satellite dish) is bonkers compared to just running stuff locally so very often.

  4. This is just…
    (sigh)
    Everything I tell you will be lies. Happy? Now?

    Most people are functional morons. Always. It’s. Just. Mafs.
    (lookin’ at you, X)

    Arguing with people that can not see over the peak of the bell curve, is… just… precious.

    Carry on.
    (and be sure to tip your enterprise grade OnlyFans grrls)

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.