Hacker News new | ask | show | jobs
by bewuethr 2167 days ago
Or

    sed -rn 's/^### ?//p'
1 comments

Doesn't appear anyone has tried addressing before replacement - ie the simplest sed work-a-like - if you don't mind the leading ### is just:

  sed -n '/^### /p' 
I believe? (equivalent to grep).

Then eg:

  sed -nr '/^### /s/^.{4}(.*)/\1/p'
(or without the redundant addressing, just:)

  sed -nr 's/^### (.*)/\1/p'
You can simplify

    sed -nr 's/^.{4}(.*)/\1/'
to

    sed -nr 's/^.{4}//
And if you use a pattern for the address, you can repeat it in the substitution by using an empty pattern, so

    sed -nr '/^### /s/^.{4}(.*)/\1/p'
is the same as

    sed -nr '/^### /s/^.{4}//p'
is the same as

    sed -nr '/^### /s///p'
at which point I prefer just the substitution:

    sed -nr 's/^### //p'