Use awk instead of sed and tr