• @mogoh@lemmy.ml
    link
    fedilink
    4911 days ago

    Which one of these commands is correct?

    A: sed -E 's/\b(\w+)\b/echo \1 | rev/g' file.txt
    B: sed 's/\b\w+\b/echo & | rev/ge' file.txt
    C: sed -E 's/(\w+)/$(echo \1 | rev)/g' file.txt
    D: sed 's/\([a-zA-Z]\+\)/\n&\n/g; s/\n\(.*\)\n/\3\2\1/g; s/\n//g' file.txt

    Chatty was so kind to transcribe. May contain errors.

    • @alienghic@slrpnk.net
      link
      fedilink
      English
      1
      edit-2
      2 days ago

      The transcription of D is wrong. It should be:

      sed 's/\([a-zA-Z]\+\)/\n&\n/g; s/\n\(.\)\(.*\)\(.\)\n/\3\2\1/g; s/\n//g' file.txt

      also D is correct, assuming file.txt contains a list of words one per line

    • @mogoh@lemmy.ml
      link
      fedilink
      3711 days ago

      Chatty claims the correct answer to be:

      Spoiler

      B

      I tried it my self and I conclude:

      Spoiler

      none is correct.

      • @UltraBlack@lemmy.world
        link
        fedilink
        1011 days ago

        Thought so lol

        A: didn’t even try what by does B: Single quotes prevent execution C: there is no way to execute commands afaik so this won’t work either D: that syntax is just wrong afaik

    • Onno (VK6FLAB)
      link
      fedilink
      17
      edit-2
      11 days ago

      Google Lens says:

      Which one of these commands is correct?
      
      A sed -e 's/\b(\w+)\b/echo \1 | rev/g' file.txt
      
      B: sed 's/b\w+\b/echo & | rev/ge' file.txt
      
      Csed -e 's/(\w+)/$(echo \1 | rev)/g' file.txt
      
      D: sed 's/([a-zA-Z]\+\)/\n&\n/g; s/\n\(\)\(.*\)\(\)\n/\3\2\1/g; s/\n//g' file.tx
      

      It’s interesting that Google doesn’t even get all the text. I had to manually extend the selection and that still misses the “t” on the end of answer D, munches C and more alarmingly changes the case for “-E”.

      • wander1236
        link
        fedilink
        3311 days ago

        OCR of fonts used to be a solved problem, but now we have AI, which can sort of do it sometimes

        • @morrowind@lemmy.ml
          link
          fedilink
          1111 days ago

          OCR was AI.

          Anyway today’s models are measurably better especially when you go beyond simple text on a clean page.

        • @vivendi@programming.dev
          link
          fedilink
          English
          411 days ago

          Any good OCR model also uses “AI”

          And LLMs are usually really good at detecting text

          Source: Had to OCR a quite a few ancient university papers