Updated Code to check the pattern with SED