dont use sed -i

-i is not POSIX, use ed instead