1. 67
  1.  

  2. 28

    Being not shell literate is one of the most surprisingly common things I’ve found in the dev world. The amount of people that will copy/paste commands over and over and over rather than just learning what the command(s) do to eventually compose your own commands as needed is just crazy to me.

    People look at you like a wizard for coming up with command strings like these when the real solution is learning the tools. After that it becomes second nature.

    Now you’re thinking with pipes

    1. 11

      Seriously. And it’s not like all of these people are bad programmers. I once helped an otherwise phenomenally skilled database engineer type sudo apt-get install mysql-server.

      1. 2

        Truth be told, I can never keep straight the various installers on different flavors of Linux. apt, emerge, yum… whenever I switch systems (and I do deal with some old ones) I have to look up which to use. Hopefully I’ve installed something recently on the machine so I can find it in the history.

      2. 4

        Agreed. At a previous company I ran a small shell intro workshop. It was originally for new hires on our graduate programme, but I ended up running it a few times for more seasoned devs too. The company blog where I wrote about it is gone now, but way back machine has my back: http://web.archive.org/web/20200927133906/http://techblog.net-a-porter.com/2013/02/shell-quickstart/#more-754

        1. 1

          I’m going to share this article with some of my friends who haven’t really grok’d shell programming yet, the examples still work and definitely force one to think with pipes. Thank you for sharing!

          1. 1

            It’s kind of you to say so! FWIW I reposted it on my personal blog, as I found the Internet Archive version to load very slowly: https://www.brautaset.org/articles/2020/shell-quickstart.html

        2. 2

          Yes!! It’s super common, even at my top 10 CS school, for CS undergrads to not be shell literate.

          1. 4

            the absolute state of CS education… hardly anyone even uses ssh nowadays

            1. 4

              I mean, they’re largely not trying to teach vocational skills other than by accident; it’s not like SSH is particularly relevant to that ‘science’ part of ‘computer science’.

              (This is one of my top peeves with CS-as-a-programming-degree; IMO it would be better taught in a vocational school)

              1. 4

                I went to a college in Ontario, Canada, which is more of a vocational/practical skills education as compared to a University which is much more academic. I studied Computer Engineering Technology. Very similar to Computer Science degrees offered at Universities. We had two classes on BASH specifically, as well as three classes on C. The first class, an introduction to the language, was taught inside VisualStudio. The second two were all taught using GCC and GDB.

                I have worked alongside CS grads from universities here and they are perplexed by not only the shell, but not using Windows as a main driver for every day development (I work mostly in web). Its interesting to see so many people head to university because of weird negative associations to college there are out there - despite more practical knowledge being taught at colleges.

                1. 2

                  I can assure you the decline in shell usage is not due to making good on the name of the degree. If anything curricula are moving in a vocational direction.

                  FWIW even academic CS research is mostly engineering, not science, and for that SSH is quite relevant.

                2. 3

                  Expecting a computer scientist to know intracracies of the Unix shell is like expecting a physicist to wrench on an engine.

                  1. 1

                    But almost all computer scientists are proficient with the Unix shell.

                    1. 3

                      Citation most definitely needed…

                      1. 1

                        You’ll have to take my word for it as someone who claims to be a computer science grad student on the Internet.

                        1. 1

                          On the internet, no-one knows you’re a dog … or a computer scientist.

                          1. 1

                            yup

                3. 2

                  Yep. It was incredibly shocking to me when I conducted a workshop on reverse engineering on campus, and the attendees weren’t able to navigate the filesystem to run gdb.

                  1. 1

                    Curious as to why their systems were configured such that gdb was not in their path and they could just invoke it without having to navigate the file system.

                    1. 2

                      I should’ve been clearer—I meant navigate the filesystem to run gdb against a program. In thid case, the program was in the downloads folder.

                  2. 1

                    I think there’s a difference between CS education and IT education.

                    Some universities and private schools focus mainly on using those tools rather than the underlying concepts.

                    For example, take cryptography, some education will focus on the math, and some other on the use case (like where signing is used how to practically use it etc…).

                4. 19

                  ITT: Just because it is necessary to remember and understand a language popularized not because it was good, bit because it is everywhere, doesn’t mean it should be celebrated.

                  1. 4

                    The example is not particularly compelling either; all the steps involving git status, awk, etc can be trivially replicated in Emacs buffers, but in a way that’s interactive so you can pause in the middle and manually inspect, save, or fix up the data if it didn’t behave the way you expected. And then you can build pipelines that operate on structured data and higher-order functions instead of just streams of bytes.

                  2. 12

                    Ah, of course, in Emacs one would just do C-x v d to open VC Directory Mode, go to the first removed file, hit M to mark (i.e. select) all files with the similar status to mark all files that have been deleted. Then C-x v u (vc-revert) to undelete those files.

                    edit: the joke

                    1. 7

                      two of the most important things i learned: touch typing and shell/unix fluency.

                      i know it’s not always fair, but if someone says they’re a programmer and they’re not familiar enough with the shell to do basic things like navigate the file system, i think less of them. a carpenter learns how to use their tools, and technology craftspeople should learn theirs.

                      1. 6

                        For the modern day, jq is absolutely essential. It’s like cut but for software made in the last 15 years. It’s starting to ship by default in more systems, but still unfortunately rare.

                        1. 5

                          I use jq almost daily at work to filter specific things in API responses when creating bug tickets. It is way easier to reproduce a problem with a curl | jq command instead of getting a screenshot where the interesting part of the JSON response is highlighted (let alone that the screenshot editing takes way longer than constructing the curl | jq example).

                        2. 6

                          I wish there was more material on becoming Powershell-literate, specifically. Most of the stuff out there is just for sysadmins, I’d love a more programmer oriented bent. Maybe it’d make me miss linux less!

                          1. 3

                            Powershell always seemed really verbose and and a lot of typing to me; not bad for some tasks, but also not great for interactive usage.

                            1. 3

                              First-class tab completion available for all cmdlets is a big part of making it suck less.

                            2. 2

                              I hard-abandoned Powershell after I realized that it returns different shaped data types depending on if a command returns zero, one or more items. I forget what the scenario was. I initially started building Jump-Location in pure powershell but abandoned it for a C# commandlet after this experience.

                              1. 2

                                I’ve always been a Windows focused programmer, but I’ve felt that PowerShell has always been an IT/Sysadmin tool rather than programmer focused. These days I just use WSL and life is just better.

                              2. 4

                                Learning to use the shell is so underrated.

                                It’s like LEGOs for software. You have absurdly stable building blocks (Gnu Tools + pipes), that pretty mcuh works everywhere, and there’s no limit to what you can make.

                                After the learning curve, making scripts becomes incredibly fun.

                                1. 3

                                  I’d point out that not all programming disciplines require significant shell expertise, and the idea that you “ought” to be “literate” in shell if you’re a programmer makes implicit judgements about the boundaries around who gets to be a programmer and how smart they are.

                                  I’ve had my moments of needing to assemble significant shell pipelines. I’ve also gotten by for months at a time with simply treating the shell(s) as an input for running single commands or very simple pipelines with common args. It really depends on what kind of work you’re doing. I’ve never committed the flags of sed, awk, or jq to memory.

                                  1. 3

                                    In fairness to GUIs, for a reasonable git IDE plugin, the first example would be click first deleted file, scroll, shift click last deleted file, right click, click checkout.

                                    I prefer the shell, and probably would have done it the same way as the author simply because I don’t typically have any kind of git GUI open. But GUIs have their place.

                                    My go-to example is mass renaming files. I will never in my entire life rename 200+ files manually. But I also don’t do anything like that often enough to have a dedicated GUI program capable of the task.

                                    1. 1

                                      For renaming loads of files, vidir (often included in moreutils) is quite nice. It gives you a list of files in your $EDITOR and so you can use whatever power your editor provides to do mass renames.

                                      1. 2

                                        I typically just use a bash for loop. The ${var#prefix} and ${var%suffix} variable substitutions usually do the trick. ${var/pattern/replace} otherwise.

                                        That said, I didn’t know about vidir and it looks extremely powerful. Thanks for the tip!

                                        1. 1

                                          zmv is also quite nice for this: zmv '(*).jpg' '$1.jpeg'. The globbing makes more complex substitutions easier IMO. But of course it’s less portable as it requires zsh.

                                          1. 1

                                            There’s also rename (or prename) as (was) shipped with Perl. It might be a separate package nowadays.

                                        2. 1

                                          Emacs also has similar functionality built in.

                                      2. 3

                                        being shell literate is also easily in the top 10 things that will help non-programmers efficively ue their computers. The number of times I’ve seen someine bulk-rename files by hand…

                                        1. 1

                                          I chuckled at the use case of “playing 50 videos”.

                                          1. 1

                                            Being shell literate is high on the list of top things programmers can do to most benefit users. I’ve seen non-programmers do all kinds of work through the shell.

                                            1. 1

                                              For the first task with “undeleting” files using Git you can go even shorter:

                                              git ls-files -d -z | xargs -0 git checkout --
                                              
                                              1. 4

                                                I would offer hg revert "set:deleted()", but then there’s no pipeline left…

                                                1. 3

                                                  That’s a shell-golf hole in one!