sed syntax frustrating, will try perl -pie or explore other alternatives