• CrazyLikeGollum@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 months ago

      Or scripts for basically any other variant of the Bourne shell. They are, for the most part, very cross compatible.

      • Tinidril@midwest.social
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 months ago

        That’s the only reason I’ve ever done much of anything in shell script. As a network administrator I’ve worked many network appliances running on some flavor of Unix and the one language I can count on to be always available is bash. It has been well worth knowing for just that reason.

      • BeigeAgenda@lemmy.ca
        link
        fedilink
        arrow-up
        0
        ·
        2 months ago

        I wrote a script to do backups on a ESXi it uses Busybox’s ASH, one thing I learned after spending hours debugging my scripts was that ASH does not support arrays so you have to do everything with temporary files.

        • YouAreLiterallyAnNPC@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          2 months ago

          There actually is an array in any POSIX shell. You get one array per file/function. It just feels bad to use it. You can abuse ‘set – 1 2 3 4’ to act as a proper array. You can then use ‘for’ without ‘in’ to iterate over it.

          for i; do echo $i; done.

          Use shift <number> to pop items off.

          If I really have to use something more complex, I’ll reach for mkfifo instead so I can guarantee the data can only be consumed once without manipulating entries.

  • perishthethought@lemm.ee
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    I don’t normally say this, but the AI tools I’ve used to help me write bash were pretty much spot on.

    • SpaceNoodle@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      2 months ago

      Yeah, an LLM can quickly parrot some basic boilerplate that’s showed up in its training data a hundred times.

    • henfredemars@infosec.pub
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 months ago

      For building a quick template that I can tweak to my needs, it works really well. I just don’t find it to be an intuitive scripting language.

    • marduk@lemmy.sdf.org
      link
      fedilink
      arrow-up
      0
      ·
      2 months ago

      Yes, with respect to the grey bearded uncles and aunties; as someone who never “learned” bash, in 2025 I’m letting a LLM do the bashing for me.

  • conditional_soup@lemm.ee
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    2 months ago

    Regex

    Edit: to everyone who responded, I use regex infrequently enough that the knowledge never really crystalizes. By the time I need it for this one thing again, I haven’t touched it in like a year.

    • kameecoding@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      2 months ago

      Most of regex is pretty basic and easy to learn, it’s the look ahead and look behind that are the killers imo

        • activ8r@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          0
          ·
          2 months ago

          I know that LLMs are probably very helpful for people who are just getting started, but you will never understand it if you can’t grasp the fundamentals. Don’t let “AI” make you lazy. If you do use LLMs make sure you understand the output it’s giving you enough to replicate it yourself.

          This may not be applicable to you specifically, but I think this is nice info to have here for others.

    • Kissaki@programming.dev
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 months ago

      You always forget regex syntax?

      I’ve always found it simple to understand and remember. Even over many years and decades, I’ve never had issues reading or writing simple regex syntax (excluding the flags and shorthands) even after long regex breaks.

      • Akito@lemmy.zip
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 months ago

        It’s not about the syntax itself, it’s about which syntax to use. There are different ones and remembering which one is for which language is tough.

          • ewenak@jlai.lu
            link
            fedilink
            arrow-up
            0
            ·
            2 months ago

            There is the “very magic” mode for vim regexes. It’s not the exact PCRE syntax, but it’s pretty close. You only need to add \v before the expression to use it. There is no permanent mode / option though. (I think you can remap the commands, like / to /\v)

        • Lehmanator@programming.dev
          link
          fedilink
          English
          arrow-up
          0
          ·
          2 months ago

          This is exactly it. Regex is super simple. The difficulty is maintaining a mental mapping between language/util <-> regex engine <-> engine syntax & character class names. It gets worse when utils also conditionally enable extended syntaxes with flags or options.

          The hardest part is remembering whether you need to use \w or [:alnum:].

          Way too few utils actually mention which syntax they use too. Most just say something accepts a “regular expression”, which is totally ambiguous.

    • 9point6@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      2 months ago

      You get used to it, I don’t even see the code—I just see: group… pattern… read-ahead…

      • traches@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        0
        ·
        edit-2
        2 months ago

        I’d been considering it for awhile, but thought it wasn’t worth the trouble of switching until I realized just how often I do things the tedious manual way because writing a bash script to do it is so arcane

  • KazuchijouNo@lemy.lol
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    Today I tried to write bash (I think)

    I grabbed a bunch of commands, slapped a bunch of “&&” to string them together and saved them to a .sh file.

    It didn’t work as expected and I did not, at all, look at any documentation during the process. (This is obviously on me, I’ll try harder next time)

    • DeRp_DaWg@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      2 months ago

      I try to remember to use man when learning a new command/program. And I almost always half-ass it and press the search button immediately to find whatever flag i need.

  • synae[he/him]@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    Incredibly true for me these days. But don’t fret, shellcheck and tldp.org is all you need. And maybe that one stackoverflow answer about how to get the running script’s directory

    • cm0002@lemmy.worldOP
      link
      fedilink
      arrow-up
      0
      ·
      2 months ago

      For a defacto windows admin my Powershell skills are…embarrassing lol but I’m getting there!

    • DigitalDruid@lemmy.sdf.org
      link
      fedilink
      arrow-up
      0
      ·
      2 months ago

      eh I had an entire career based on regex and i still used rubular on the daily once someone made it. there’s too many corner cases for a biological entity!

      • MechanicalJester@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        2 months ago

        Mastered as in I could teach it to others, and assemble many complicated rules for many complicated patterns.

        I am always impressed with folks that retain it.

        I would a ton of it for a month or two, and then do nothing with it again for more than a year or more.

        It takes a lot for permanent burn-in for me. That’s the curse. The blessing is that I learn very quickly.

  • Rose@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    There’s always the old piece of wisdom from the Unix jungle: “If you write a complex shellscript, sooner or later you’ll wish you wrote it in a real programming language.”

    I wrote a huge PowerShell script over the past few years. I was like “Ooh, guess this is a resume item if anyone asks me if I know PowerShell.” …around the beginning of the year I rewrote the bloody thing in Python and I have zero regrets. It’s no longer a Big Mush of Stuff That Does a Thing. It’s got object orientation now. Design patterns. Things in independent units. Shit like that.

  • Cold_Brew_Enema@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    Me with powershell. I’ll write a pretty complex script, not write powershell for 3 months, come back and have to completely relearn it.