[Sed] move replace outside the replacement loop