Well, you probably could do it in sed, but there’s a reason both sed and awk are available, and that’s because they work well together and are fairly complementary. In fact, the best book, is the ORA sed & awk book. Of course everything you can do with them can be done with perl, so if you grok that, use perl instead, but for some of us old coots, perl is still a write-only language, so….