News for hackers. Stuff that matters.
Re:Batch editing files with ed by atsaloli on Saturday May 12, 2018 @03:08PM (#17055513)
Nice article, good to hear ed is not dead. =)

You could also just add the text after the matching line. A little simpler and more straight forward.

    $ cat > /tmp/ed-script
    /baz
    a
      - elephants
    .
    w
    q
    $ cat /tmp/2
    foo:
      - bar
      - baz
      - bananas
    $ cat /tmp/ed-script | ed /tmp/2
    33
      - baz
    47
    $ cat /tmp/2
    foo:
      - bar
      - baz
      - elephants
      - bananas
    $·
Re:Batch editing files with ed by fiddlerwoaroof on Saturday May 12, 2018 @04:39PM (#17055901)
I don’t think matches the spec that the new line has the same number of leading spaces as the surrounding lines
Re:Batch editing files with ed by fiddlerwoaroof on Saturday May 12, 2018 @04:41PM (#17055916)
Weird, after rereading the article, it seems like I may have imagined that part.
Re:Batch editing files with ed by bramblerose on Saturday May 12, 2018 @05:06PM (#17056002)
An older version of the article contained the following:

> I had one extra weird requirement which was that some of the lines were indented with 2 spaces, and some with 4 spaces. The - elephant line needed to have the same indentation as the previous line.

Re:Batch editing files with ed by atsaloli on Monday May 14, 2018 @03:27PM (#17068624)
Well! That explains the .t. Thanks! :)
Re:Batch editing files with ed by samatman on Saturday May 12, 2018 @03:21PM (#17055576)
My guess is that the - is replacing something like an org-mode cookie, which could be in a few states that one might want to preserve.