Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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'




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: