Replace non-portable sed code with some simple awk