• mogoh@lemmy.ml
    link
    fedilink
    arrow-up
    42
    arrow-down
    1
    ·
    3 months 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.

    • mogoh@lemmy.ml
      link
      fedilink
      arrow-up
      29
      arrow-down
      1
      ·
      3 months 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
        arrow-up
        11
        arrow-down
        1
        ·
        3 months 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