https://news.ycombinator.com/item?id=13451454
For sed, the best resource is likely the free "UNIX Bookshelf" from O'Reilly that can be found online; this contains a book specifically focusing on Sed and Awk.
https://freecomputerbooks.com/The-Unix-CD-Bookshelf-Version-...
[0]: https://www.grymoire.com/Unix/Sed.html
Edit: That said, I don't even want to start dissecting the submitted code.
* https://learnbyexample.github.io/learn_gnused/
* https://learnbyexample.github.io/learn_gnuawk/
I also wrote TUI apps for interactive exercises (grep, sed, awk, etc): https://github.com/learnbyexample/TUI-apps
I've had some fun using awk to generate C# classes for an Ultima Online emulator.
If you're okay with gawk, most implementations ship with gawkextlib, which has readfile(), and you also have FIELDWIDTHS.