News for hackers. Stuff that matters.
Re:Useful sed scripts and patterns by asicsp on Friday November 12, 2021 @01:26AM (#29196797)
Nice descriptions, but some of them need changes to match the command. For example:

    sed '1~2p' file.txt #needs -n option

    s '1,$ s/foo/bar/' file.txt #s --> sed and 1,$ --> 5,$
Many commands using `-r` do not need the option for the command used (for ex: `sed -r '/start/q'`). Also, using `-E` is preferred instead of `-r` since some of the other implementations support this option but not `-r`.

---

I wrote a book on GNU sed with plenty of examples and exercises: https://github.com/learnbyexample/learn_gnused It is free to read online and there's a detailed chapter for learning BRE/ERE regex flavor as well.

Re:Useful sed scripts and patterns by adrianscheff on Friday November 12, 2021 @07:38AM (#29198711)
Thank you for the constructive feedback, I've corrected the mistakes pointed out. I've also changed -r to -E based on your (and some other people's) advice.