Asking them here should be fine, it generally makes more sense to just ask the question first rather than ask to ask the question. If it's in the wrong place then you'll just piss off a mod cause they'll have to move it
For both of those sed can do everything you want. Google it and scan the man page, it can do heaps of cool schtuff